From 728e49ed9107095c0fce2fd4d54d7c093a2dab1c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 28 Apr 2025 16:09:46 +0000 Subject: [PATCH] CodeGen from PR 34235 in Azure/azure-rest-api-specs Merge 1b6e2797d7b6f57c2dfa39949546227714b5a68a into 30355bb16e2dc552d4e91556a87ae38e6d9c0d46 --- .../Azure.AI.Agents.Persistent.sln | 56 + .../Azure.AI.Agents.Persistent/CHANGELOG.md | 11 + .../Directory.Build.props | 6 + sdk/ai/Azure.AI.Agents.Persistent/README.md | 107 ++ .../src/Azure.AI.Agents.Persistent.csproj | 20 + ...AgentsPersistentClientBuilderExtensions.cs | 46 + .../AIAgentsPersistentModelFactory.cs | 1160 +++++++++++++++++ .../AISearchIndexResource.Serialization.cs | 197 +++ .../src/Generated/AISearchIndexResource.cs | 94 ++ .../Generated/AgentsAdministrationClient.cs | 1138 ++++++++++++++++ .../AgentsAdministrationClientOptions.cs | 37 + .../src/Generated/AzureAISearchQueryType.cs | 60 + .../AzureAISearchResource.Serialization.cs | 159 +++ .../src/Generated/AzureAISearchResource.cs | 72 + ...ureAISearchToolDefinition.Serialization.cs | 126 ++ .../Generated/AzureAISearchToolDefinition.cs | 29 + .../AzureFunctionBinding.Serialization.cs | 150 +++ .../src/Generated/AzureFunctionBinding.cs | 80 ++ .../src/Generated/AzureFunctionBindingType.cs | 48 + ...AzureFunctionStorageQueue.Serialization.cs | 150 +++ .../Generated/AzureFunctionStorageQueue.cs | 82 ++ ...ureFunctionToolDefinition.Serialization.cs | 134 ++ .../Generated/AzureFunctionToolDefinition.cs | 44 + ...ustomSearchToolDefinition.Serialization.cs | 134 ++ .../BingCustomSearchToolDefinition.cs | 44 + ...ngGroundingToolDefinition.Serialization.cs | 134 ++ .../Generated/BingGroundingToolDefinition.cs | 44 + ...InterpreterToolDefinition.Serialization.cs | 126 ++ .../CodeInterpreterToolDefinition.cs | 29 + ...deInterpreterToolResource.Serialization.cs | 184 +++ .../Generated/CodeInterpreterToolResource.cs | 77 ++ .../ConnectedAgentDetails.Serialization.cs | 158 +++ .../src/Generated/ConnectedAgentDetails.cs | 89 ++ ...nectedAgentToolDefinition.Serialization.cs | 134 ++ .../Generated/ConnectedAgentToolDefinition.cs | 44 + .../CreateAgentRequest.Serialization.cs | 379 ++++++ .../src/Generated/CreateAgentRequest.cs | 189 +++ .../CreateMessageRequest.Serialization.cs | 222 ++++ .../src/Generated/CreateMessageRequest.cs | 159 +++ .../CreateRunRequest.Serialization.cs | 530 ++++++++ .../src/Generated/CreateRunRequest.cs | 281 ++++ ...CreateThreadAndRunRequest.Serialization.cs | 513 ++++++++ .../Generated/CreateThreadAndRunRequest.cs | 274 ++++ .../CreateThreadRequest.Serialization.cs | 215 +++ .../src/Generated/CreateThreadRequest.cs | 83 ++ ...ctorStoreFileBatchRequest.Serialization.cs | 199 +++ .../CreateVectorStoreFileBatchRequest.cs | 83 ++ ...ateVectorStoreFileRequest.Serialization.cs | 175 +++ .../Generated/CreateVectorStoreFileRequest.cs | 81 ++ .../CreateVectorStoreRequest.Serialization.cs | 255 ++++ .../src/Generated/CreateVectorStoreRequest.cs | 95 ++ .../src/Generated/DoneEvent.cs | 48 + .../src/Generated/ErrorEvent.cs | 48 + .../src/Generated/File.Serialization.cs | 164 +++ .../src/Generated/File.cs | 184 +++ .../FileSearchRankingOptions.Serialization.cs | 150 +++ .../src/Generated/FileSearchRankingOptions.cs | 81 ++ ...FileSearchToolCallContent.Serialization.cs | 150 +++ .../Generated/FileSearchToolCallContent.cs | 80 ++ .../FileSearchToolCallContentType.cs | 48 + .../FileSearchToolDefinition.Serialization.cs | 141 ++ .../src/Generated/FileSearchToolDefinition.cs | 34 + ...archToolDefinitionDetails.Serialization.cs | 164 +++ .../FileSearchToolDefinitionDetails.cs | 77 ++ .../FileSearchToolResource.Serialization.cs | 184 +++ .../src/Generated/FileSearchToolResource.cs | 85 ++ .../src/Generated/FileState.cs | 75 ++ .../src/Generated/Files.cs | 665 ++++++++++ .../Generated/FunctionName.Serialization.cs | 142 ++ .../src/Generated/FunctionName.cs | 75 ++ .../FunctionToolDefinition.Serialization.cs | 134 ++ .../src/Generated/FunctionToolDefinition.cs | 44 + .../src/Generated/ImageDetailLevel.cs | 54 + .../src/Generated/IncompleteDetailsReason.cs | 51 + .../IncompleteRunDetails.Serialization.cs | 142 ++ .../src/Generated/IncompleteRunDetails.cs | 72 + .../src/Generated/Internal/Argument.cs | 129 ++ .../Internal/ChangeTrackingDictionary.cs | 167 +++ .../Generated/Internal/ChangeTrackingList.cs | 153 +++ .../Internal/ModelSerializationExtensions.cs | 399 ++++++ .../MultipartFormDataRequestContent.cs | 203 +++ .../src/Generated/Internal/Optional.cs | 51 + .../Internal/Utf8JsonRequestContent.cs | 55 + ...ternalAgentDeletionStatus.Serialization.cs | 158 +++ .../Generated/InternalAgentDeletionStatus.cs | 85 ++ .../InternalAgentDeletionStatusObject.cs | 48 + ...alAzureFunctionDefinition.Serialization.cs | 158 +++ .../InternalAzureFunctionDefinition.cs | 89 ++ ...nterpreterToolCallDetails.Serialization.cs | 160 +++ .../InternalCodeInterpreterToolCallDetails.cs | 95 ++ ...nternalFileDeletionStatus.Serialization.cs | 158 +++ .../Generated/InternalFileDeletionStatus.cs | 85 ++ .../InternalFileDeletionStatusObject.cs | 48 + .../InternalFileListResponse.Serialization.cs | 160 +++ .../src/Generated/InternalFileListResponse.cs | 81 ++ .../InternalFileListResponseObject.cs | 48 + ...nternalFunctionDefinition.Serialization.cs | 168 +++ .../Generated/InternalFunctionDefinition.cs | 115 ++ ...alMessageImageFileDetails.Serialization.cs | 142 ++ .../InternalMessageImageFileDetails.cs | 75 ++ ...nternalMessageTextDetails.Serialization.cs | 160 +++ .../Generated/InternalMessageTextDetails.cs | 95 ++ ...geTextFileCitationDetails.Serialization.cs | 150 +++ .../InternalMessageTextFileCitationDetails.cs | 82 ++ ...essageTextFilePathDetails.Serialization.cs | 142 ++ .../InternalMessageTextFilePathDetails.cs | 75 ++ ...edFunctionToolCallDetails.Serialization.cs | 150 +++ ...InternalRequiredFunctionToolCallDetails.cs | 82 ++ ...epFunctionToolCallDetails.Serialization.cs | 170 +++ .../InternalRunStepFunctionToolCallDetails.cs | 88 ++ ...lSubmitToolOutputsDetails.Serialization.cs | 152 +++ .../InternalSubmitToolOutputsDetails.cs | 88 ++ .../src/Generated/ListSortOrder.cs | 51 + .../MessageAttachment.Serialization.cs | 197 +++ .../src/Generated/MessageAttachment.cs | 121 ++ .../src/Generated/MessageBlockType.cs | 54 + .../Generated/MessageContent.Serialization.cs | 134 ++ .../src/Generated/MessageContent.cs | 69 + .../Generated/MessageDelta.Serialization.cs | 160 +++ .../src/Generated/MessageDelta.cs | 94 ++ .../MessageDeltaChunk.Serialization.cs | 158 +++ .../src/Generated/MessageDeltaChunk.cs | 87 ++ .../src/Generated/MessageDeltaChunkObject.cs | 48 + .../MessageDeltaContent.Serialization.cs | 136 ++ .../src/Generated/MessageDeltaContent.cs | 80 ++ ...sageDeltaImageFileContent.Serialization.cs | 147 +++ .../Generated/MessageDeltaImageFileContent.cs | 41 + ...ltaImageFileContentObject.Serialization.cs | 145 +++ .../MessageDeltaImageFileContentObject.cs | 65 + ...essageDeltaTextAnnotation.Serialization.cs | 137 ++ .../Generated/MessageDeltaTextAnnotation.cs | 80 ++ .../MessageDeltaTextContent.Serialization.cs | 147 +++ .../src/Generated/MessageDeltaTextContent.cs | 41 + ...ageDeltaTextContentObject.Serialization.cs | 170 +++ .../MessageDeltaTextContentObject.cs | 78 ++ ...extFileCitationAnnotation.Serialization.cs | 195 +++ .../MessageDeltaTextFileCitationAnnotation.cs | 53 + ...eCitationAnnotationObject.Serialization.cs | 156 +++ ...geDeltaTextFileCitationAnnotationObject.cs | 69 + ...ltaTextFilePathAnnotation.Serialization.cs | 195 +++ .../MessageDeltaTextFilePathAnnotation.cs | 53 + ...tFilePathAnnotationObject.Serialization.cs | 145 +++ ...essageDeltaTextFilePathAnnotationObject.cs | 65 + ...TextUrlCitationAnnotation.Serialization.cs | 176 +++ .../MessageDeltaTextUrlCitationAnnotation.cs | 54 + ...ltaTextUrlCitationDetails.Serialization.cs | 153 +++ .../MessageDeltaTextUrlCitationDetails.cs | 79 ++ .../MessageImageFileContent.Serialization.cs | 134 ++ .../src/Generated/MessageImageFileContent.cs | 44 + .../MessageImageFileParam.Serialization.cs | 157 +++ .../src/Generated/MessageImageFileParam.cs | 79 ++ .../MessageImageUrlParam.Serialization.cs | 157 +++ .../src/Generated/MessageImageUrlParam.cs | 79 ++ .../MessageIncompleteDetails.Serialization.cs | 142 ++ .../src/Generated/MessageIncompleteDetails.cs | 72 + .../MessageIncompleteDetailsReason.cs | 60 + .../MessageInputContentBlock.Serialization.cs | 135 ++ .../src/Generated/MessageInputContentBlock.cs | 69 + ...essageInputImageFileBlock.Serialization.cs | 134 ++ .../Generated/MessageInputImageFileBlock.cs | 44 + ...MessageInputImageUrlBlock.Serialization.cs | 134 ++ .../Generated/MessageInputImageUrlBlock.cs | 44 + .../MessageInputTextBlock.Serialization.cs | 134 ++ .../src/Generated/MessageInputTextBlock.cs | 44 + .../src/Generated/MessageRole.cs | 51 + .../src/Generated/MessageStatus.cs | 54 + .../src/Generated/MessageStreamEvent.cs | 60 + .../MessageTextAnnotation.Serialization.cs | 137 ++ .../src/Generated/MessageTextAnnotation.cs | 83 ++ .../MessageTextContent.Serialization.cs | 134 ++ .../src/Generated/MessageTextContent.cs | 44 + ...extFileCitationAnnotation.Serialization.cs | 176 +++ .../MessageTextFileCitationAnnotation.cs | 64 + ...ageTextFilePathAnnotation.Serialization.cs | 176 +++ .../MessageTextFilePathAnnotation.cs | 55 + ...TextUrlCitationAnnotation.Serialization.cs | 176 +++ .../MessageTextUrlCitationAnnotation.cs | 55 + ...ageTextUrlCitationDetails.Serialization.cs | 153 +++ .../MessageTextUrlCitationDetails.cs | 79 ++ .../src/Generated/Messages.cs | 667 ++++++++++ ...osoftFabricToolDefinition.Serialization.cs | 134 ++ .../MicrosoftFabricToolDefinition.cs | 44 + .../ModifyVectorStoreRequest.Serialization.cs | 213 +++ .../src/Generated/ModifyVectorStoreRequest.cs | 74 ++ .../src/Generated/OpenAIFile.Serialization.cs | 217 +++ .../src/Generated/OpenAIFile.cs | 113 ++ .../src/Generated/OpenAIFileObject.cs | 48 + .../src/Generated/OpenAIFilePurpose.cs | 66 + ...OpenAIPageableListOfAgent.Serialization.cs | 190 +++ .../Generated/OpenAIPageableListOfAgent.cs | 101 ++ .../OpenAIPageableListOfAgentObject.cs | 48 + ...PageableListOfAgentThread.Serialization.cs | 190 +++ .../OpenAIPageableListOfAgentThread.cs | 101 ++ .../OpenAIPageableListOfAgentThreadObject.cs | 48 + ...enAIPageableListOfRunStep.Serialization.cs | 190 +++ .../Generated/OpenAIPageableListOfRunStep.cs | 101 ++ .../OpenAIPageableListOfRunStepObject.cs | 48 + ...geableListOfThreadMessage.Serialization.cs | 190 +++ .../OpenAIPageableListOfThreadMessage.cs | 101 ++ ...OpenAIPageableListOfThreadMessageObject.cs | 48 + ...AIPageableListOfThreadRun.Serialization.cs | 190 +++ .../OpenAIPageableListOfThreadRun.cs | 101 ++ .../OpenAIPageableListOfThreadRunObject.cs | 48 + ...PageableListOfVectorStore.Serialization.cs | 190 +++ .../OpenAIPageableListOfVectorStore.cs | 101 ++ ...ableListOfVectorStoreFile.Serialization.cs | 190 +++ .../OpenAIPageableListOfVectorStoreFile.cs | 101 ++ ...enAIPageableListOfVectorStoreFileObject.cs | 48 + .../OpenAIPageableListOfVectorStoreObject.cs | 48 + ...enApiAnonymousAuthDetails.Serialization.cs | 126 ++ .../Generated/OpenApiAnonymousAuthDetails.cs | 29 + .../OpenApiAuthDetails.Serialization.cs | 135 ++ .../src/Generated/OpenApiAuthDetails.cs | 69 + .../src/Generated/OpenApiAuthType.cs | 59 + ...nApiConnectionAuthDetails.Serialization.cs | 134 ++ .../Generated/OpenApiConnectionAuthDetails.cs | 44 + ...iConnectionSecurityScheme.Serialization.cs | 142 ++ .../OpenApiConnectionSecurityScheme.cs | 75 ++ ...OpenApiFunctionDefinition.Serialization.cs | 207 +++ .../Generated/OpenApiFunctionDefinition.cs | 139 ++ ...OpenApiManagedAuthDetails.Serialization.cs | 134 ++ .../Generated/OpenApiManagedAuthDetails.cs | 44 + ...nApiManagedSecurityScheme.Serialization.cs | 142 ++ .../Generated/OpenApiManagedSecurityScheme.cs | 75 ++ .../OpenApiToolDefinition.Serialization.cs | 134 ++ .../src/Generated/OpenApiToolDefinition.cs | 44 + .../PersistentAgent.Serialization.cs | 379 ++++++ .../src/Generated/PersistentAgent.cs | 238 ++++ .../src/Generated/PersistentAgentObject.cs | 48 + .../Generated/PersistentAgentStreamEvent.cs | 137 ++ .../PersistentAgentThread.Serialization.cs | 215 +++ .../src/Generated/PersistentAgentThread.cs | 110 ++ ...gentThreadCreationOptions.Serialization.cs | 215 +++ .../PersistentAgentThreadCreationOptions.cs | 83 ++ .../Generated/PersistentAgentThreadObject.cs | 48 + ...ntAgentsApiResponseFormat.Serialization.cs | 149 +++ .../PersistentAgentsApiResponseFormat.cs | 68 + .../PersistentAgentsApiResponseFormatMode.cs | 51 + ...PersistentAgentsApiToolChoiceOptionMode.cs | 51 + ...tentAgentsNamedToolChoice.Serialization.cs | 157 +++ .../PersistentAgentsNamedToolChoice.cs | 76 ++ .../PersistentAgentsNamedToolChoiceType.cs | 72 + .../Generated/RequiredAction.Serialization.cs | 133 ++ .../src/Generated/RequiredAction.cs | 69 + .../RequiredFunctionToolCall.Serialization.cs | 140 ++ .../src/Generated/RequiredFunctionToolCall.cs | 47 + .../RequiredToolCall.Serialization.cs | 135 ++ .../src/Generated/RequiredToolCall.cs | 83 ++ .../src/Generated/ResponseFormat.cs | 51 + .../ResponseFormatJsonSchema.Serialization.cs | 168 +++ .../src/Generated/ResponseFormatJsonSchema.cs | 115 ++ ...ponseFormatJsonSchemaType.Serialization.cs | 150 +++ .../Generated/ResponseFormatJsonSchemaType.cs | 80 ++ .../ResponseFormatJsonSchemaTypeType.cs | 48 + .../src/Generated/RunAdditionalFieldList.cs | 48 + .../RunCompletionUsage.Serialization.cs | 158 +++ .../src/Generated/RunCompletionUsage.cs | 84 ++ .../src/Generated/RunError.Serialization.cs | 150 +++ .../src/Generated/RunError.cs | 82 ++ .../src/Generated/RunStatus.cs | 69 + .../src/Generated/RunStep.Serialization.cs | 377 ++++++ .../src/Generated/RunStep.cs | 178 +++ ...StepAzureAISearchToolCall.Serialization.cs | 151 +++ .../Generated/RunStepAzureAISearchToolCall.cs | 50 + ...StepBingGroundingToolCall.Serialization.cs | 151 +++ .../Generated/RunStepBingGroundingToolCall.cs | 50 + ...odeInterpreterImageOutput.Serialization.cs | 134 ++ .../RunStepCodeInterpreterImageOutput.cs | 44 + ...InterpreterImageReference.Serialization.cs | 142 ++ .../RunStepCodeInterpreterImageReference.cs | 75 ++ ...pCodeInterpreterLogOutput.Serialization.cs | 134 ++ .../RunStepCodeInterpreterLogOutput.cs | 44 + ...epCodeInterpreterToolCall.Serialization.cs | 140 ++ .../RunStepCodeInterpreterToolCall.cs | 50 + ...InterpreterToolCallOutput.Serialization.cs | 134 ++ .../RunStepCodeInterpreterToolCallOutput.cs | 69 + .../RunStepCompletionUsage.Serialization.cs | 158 +++ .../src/Generated/RunStepCompletionUsage.cs | 84 ++ ...nStepCustomSearchToolCall.Serialization.cs | 151 +++ .../Generated/RunStepCustomSearchToolCall.cs | 50 + .../Generated/RunStepDelta.Serialization.cs | 149 +++ .../src/Generated/RunStepDelta.cs | 73 ++ .../RunStepDeltaChunk.Serialization.cs | 158 +++ .../src/Generated/RunStepDeltaChunk.cs | 87 ++ .../src/Generated/RunStepDeltaChunkObject.cs | 48 + ...terpreterDetailItemObject.Serialization.cs | 170 +++ ...tepDeltaCodeInterpreterDetailItemObject.cs | 82 ++ ...odeInterpreterImageOutput.Serialization.cs | 147 +++ .../RunStepDeltaCodeInterpreterImageOutput.cs | 41 + ...erpreterImageOutputObject.Serialization.cs | 145 +++ ...epDeltaCodeInterpreterImageOutputObject.cs | 65 + ...aCodeInterpreterLogOutput.Serialization.cs | 143 ++ .../RunStepDeltaCodeInterpreterLogOutput.cs | 41 + ...eltaCodeInterpreterOutput.Serialization.cs | 136 ++ .../RunStepDeltaCodeInterpreterOutput.cs | 80 ++ ...taCodeInterpreterToolCall.Serialization.cs | 153 +++ .../RunStepDeltaCodeInterpreterToolCall.cs | 46 + .../RunStepDeltaDetail.Serialization.cs | 134 ++ .../src/Generated/RunStepDeltaDetail.cs | 69 + ...epDeltaFileSearchToolCall.Serialization.cs | 153 +++ .../RunStepDeltaFileSearchToolCall.cs | 46 + .../RunStepDeltaFunction.Serialization.cs | 179 +++ .../src/Generated/RunStepDeltaFunction.cs | 73 ++ ...StepDeltaFunctionToolCall.Serialization.cs | 153 +++ .../Generated/RunStepDeltaFunctionToolCall.cs | 46 + ...nStepDeltaMessageCreation.Serialization.cs | 141 ++ .../Generated/RunStepDeltaMessageCreation.cs | 34 + ...eltaMessageCreationObject.Serialization.cs | 145 +++ .../RunStepDeltaMessageCreationObject.cs | 65 + .../RunStepDeltaToolCall.Serialization.cs | 139 ++ .../src/Generated/RunStepDeltaToolCall.cs | 89 ++ ...unStepDeltaToolCallObject.Serialization.cs | 151 +++ .../Generated/RunStepDeltaToolCallObject.cs | 43 + .../Generated/RunStepDetails.Serialization.cs | 134 ++ .../src/Generated/RunStepDetails.cs | 69 + .../Generated/RunStepError.Serialization.cs | 150 +++ .../src/Generated/RunStepError.cs | 81 ++ .../src/Generated/RunStepErrorCode.cs | 51 + ...RunStepFileSearchToolCall.Serialization.cs | 140 ++ .../Generated/RunStepFileSearchToolCall.cs | 50 + ...pFileSearchToolCallResult.Serialization.cs | 183 +++ .../RunStepFileSearchToolCallResult.cs | 93 ++ ...FileSearchToolCallResults.Serialization.cs | 167 +++ .../RunStepFileSearchToolCallResults.cs | 80 ++ .../RunStepFunctionToolCall.Serialization.cs | 140 ++ .../src/Generated/RunStepFunctionToolCall.cs | 50 + ...tepMessageCreationDetails.Serialization.cs | 134 ++ .../RunStepMessageCreationDetails.cs | 44 + ...pMessageCreationReference.Serialization.cs | 142 ++ .../RunStepMessageCreationReference.cs | 75 ++ ...epMicrosoftFabricToolCall.Serialization.cs | 151 +++ .../RunStepMicrosoftFabricToolCall.cs | 50 + .../src/Generated/RunStepObject.cs | 48 + .../RunStepOpenAPIToolCall.Serialization.cs | 151 +++ .../src/Generated/RunStepOpenAPIToolCall.cs | 50 + ...RunStepSharepointToolCall.Serialization.cs | 151 +++ .../Generated/RunStepSharepointToolCall.cs | 50 + .../src/Generated/RunStepStatus.cs | 60 + .../src/Generated/RunStepStreamEvent.cs | 66 + .../RunStepToolCall.Serialization.cs | 143 ++ .../src/Generated/RunStepToolCall.cs | 83 ++ .../RunStepToolCallDetails.Serialization.cs | 144 ++ .../src/Generated/RunStepToolCallDetails.cs | 57 + .../src/Generated/RunStepType.cs | 51 + .../src/Generated/RunSteps.cs | 420 ++++++ .../src/Generated/RunStreamEvent.cs | 75 ++ .../src/Generated/Runs.cs | 1045 +++++++++++++++ .../SearchConfiguration.Serialization.cs | 150 +++ .../src/Generated/SearchConfiguration.cs | 82 ++ .../SearchConfigurationList.Serialization.cs | 152 +++ .../src/Generated/SearchConfigurationList.cs | 85 ++ .../SharepointToolDefinition.Serialization.cs | 134 ++ .../src/Generated/SharepointToolDefinition.cs | 44 + .../SubmitToolOutputsAction.Serialization.cs | 134 ++ .../src/Generated/SubmitToolOutputsAction.cs | 44 + ...itToolOutputsToRunRequest.Serialization.cs | 175 +++ .../SubmitToolOutputsToRunRequest.cs | 80 ++ .../ThreadDeletionStatus.Serialization.cs | 158 +++ .../src/Generated/ThreadDeletionStatus.cs | 85 ++ .../Generated/ThreadDeletionStatusObject.cs | 48 + .../Generated/ThreadMessage.Serialization.cs | 376 ++++++ .../src/Generated/ThreadMessage.cs | 167 +++ .../src/Generated/ThreadMessageObject.cs | 48 + .../ThreadMessageOptions.Serialization.cs | 222 ++++ .../src/Generated/ThreadMessageOptions.cs | 162 +++ .../src/Generated/ThreadRun.Serialization.cs | 650 +++++++++ .../src/Generated/ThreadRun.cs | 343 +++++ .../src/Generated/ThreadRunObject.cs | 48 + .../src/Generated/ThreadStreamEvent.cs | 48 + .../src/Generated/Threads.cs | 714 ++++++++++ .../Generated/ToolConnection.Serialization.cs | 142 ++ .../src/Generated/ToolConnection.cs | 75 ++ .../ToolConnectionList.Serialization.cs | 159 +++ .../src/Generated/ToolConnectionList.cs | 72 + .../Generated/ToolDefinition.Serialization.cs | 143 ++ .../src/Generated/ToolDefinition.cs | 69 + .../src/Generated/ToolOutput.Serialization.cs | 156 +++ .../src/Generated/ToolOutput.cs | 69 + .../Generated/ToolResources.Serialization.cs | 179 +++ .../src/Generated/ToolResources.cs | 77 ++ .../TruncationObject.Serialization.cs | 165 +++ .../src/Generated/TruncationObject.cs | 91 ++ .../src/Generated/TruncationStrategy.cs | 51 + .../UnknownMessageContent.Serialization.cs | 126 ++ .../src/Generated/UnknownMessageContent.cs | 28 + ...nknownMessageDeltaContent.Serialization.cs | 132 ++ .../Generated/UnknownMessageDeltaContent.cs | 29 + ...essageDeltaTextAnnotation.Serialization.cs | 132 ++ .../UnknownMessageDeltaTextAnnotation.cs | 29 + ...nMessageInputContentBlock.Serialization.cs | 126 ++ .../UnknownMessageInputContentBlock.cs | 28 + ...nownMessageTextAnnotation.Serialization.cs | 132 ++ .../Generated/UnknownMessageTextAnnotation.cs | 29 + ...UnknownOpenApiAuthDetails.Serialization.cs | 126 ++ .../Generated/UnknownOpenApiAuthDetails.cs | 28 + .../UnknownRequiredAction.Serialization.cs | 126 ++ .../src/Generated/UnknownRequiredAction.cs | 28 + .../UnknownRequiredToolCall.Serialization.cs | 132 ++ .../src/Generated/UnknownRequiredToolCall.cs | 29 + ...InterpreterToolCallOutput.Serialization.cs | 126 ++ ...ownRunStepCodeInterpreterToolCallOutput.cs | 28 + ...eltaCodeInterpreterOutput.Serialization.cs | 132 ++ ...nknownRunStepDeltaCodeInterpreterOutput.cs | 29 + ...UnknownRunStepDeltaDetail.Serialization.cs | 126 ++ .../Generated/UnknownRunStepDeltaDetail.cs | 28 + ...knownRunStepDeltaToolCall.Serialization.cs | 138 ++ .../Generated/UnknownRunStepDeltaToolCall.cs | 30 + .../UnknownRunStepDetails.Serialization.cs | 126 ++ .../src/Generated/UnknownRunStepDetails.cs | 28 + .../UnknownRunStepToolCall.Serialization.cs | 132 ++ .../src/Generated/UnknownRunStepToolCall.cs | 29 + .../UnknownToolDefinition.Serialization.cs | 126 ++ .../src/Generated/UnknownToolDefinition.cs | 28 + ...reChunkingStrategyRequest.Serialization.cs | 126 ++ ...knownVectorStoreChunkingStrategyRequest.cs | 28 + ...eChunkingStrategyResponse.Serialization.cs | 126 ++ ...nownVectorStoreChunkingStrategyResponse.cs | 28 + .../UpdateAgentRequest.Serialization.cs | 374 ++++++ .../src/Generated/UpdateAgentRequest.cs | 179 +++ ...preterToolResourceOptions.Serialization.cs | 159 +++ ...pdateCodeInterpreterToolResourceOptions.cs | 66 + ...SearchToolResourceOptions.Serialization.cs | 159 +++ .../UpdateFileSearchToolResourceOptions.cs | 66 + .../UpdateMessageRequest.Serialization.cs | 167 +++ .../src/Generated/UpdateMessageRequest.cs | 66 + .../UpdateRunRequest.Serialization.cs | 167 +++ .../src/Generated/UpdateRunRequest.cs | 66 + .../UpdateThreadRequest.Serialization.cs | 190 +++ .../src/Generated/UpdateThreadRequest.cs | 78 ++ ...pdateToolResourcesOptions.Serialization.cs | 179 +++ .../Generated/UpdateToolResourcesOptions.cs | 83 ++ .../UploadFileRequest.Serialization.cs | 191 +++ .../src/Generated/UploadFileRequest.cs | 85 ++ .../Generated/VectorStore.Serialization.cs | 291 +++++ .../src/Generated/VectorStore.cs | 132 ++ ...toChunkingStrategyRequest.Serialization.cs | 126 ++ .../VectorStoreAutoChunkingStrategyRequest.cs | 29 + ...oChunkingStrategyResponse.Serialization.cs | 126 ++ ...VectorStoreAutoChunkingStrategyResponse.cs | 29 + ...reChunkingStrategyRequest.Serialization.cs | 134 ++ .../VectorStoreChunkingStrategyRequest.cs | 69 + .../VectorStoreChunkingStrategyRequestType.cs | 51 + ...eChunkingStrategyResponse.Serialization.cs | 134 ++ .../VectorStoreChunkingStrategyResponse.cs | 69 + ...VectorStoreChunkingStrategyResponseType.cs | 51 + .../VectorStoreConfiguration.Serialization.cs | 152 +++ .../src/Generated/VectorStoreConfiguration.cs | 79 ++ ...VectorStoreConfigurations.Serialization.cs | 150 +++ .../Generated/VectorStoreConfigurations.cs | 82 ++ .../VectorStoreDataSource.Serialization.cs | 150 +++ .../src/Generated/VectorStoreDataSource.cs | 84 ++ .../VectorStoreDataSourceAssetType.cs | 54 + ...VectorStoreDeletionStatus.Serialization.cs | 158 +++ .../Generated/VectorStoreDeletionStatus.cs | 85 ++ .../VectorStoreDeletionStatusObject.cs | 48 + ...ctorStoreExpirationPolicy.Serialization.cs | 150 +++ .../Generated/VectorStoreExpirationPolicy.cs | 78 ++ .../VectorStoreExpirationPolicyAnchor.cs | 48 + .../VectorStoreFile.Serialization.cs | 219 ++++ .../src/Generated/VectorStoreFile.cs | 139 ++ .../VectorStoreFileBatch.Serialization.cs | 189 +++ .../src/Generated/VectorStoreFileBatch.cs | 106 ++ .../Generated/VectorStoreFileBatchObject.cs | 48 + .../Generated/VectorStoreFileBatchStatus.cs | 57 + .../src/Generated/VectorStoreFileBatches.cs | 647 +++++++++ .../VectorStoreFileCount.Serialization.cs | 180 +++ .../src/Generated/VectorStoreFileCount.cs | 96 ++ ...orStoreFileDeletionStatus.Serialization.cs | 158 +++ .../VectorStoreFileDeletionStatus.cs | 85 ++ .../VectorStoreFileDeletionStatusObject.cs | 48 + .../VectorStoreFileError.Serialization.cs | 150 +++ .../src/Generated/VectorStoreFileError.cs | 81 ++ .../src/Generated/VectorStoreFileErrorCode.cs | 54 + .../src/Generated/VectorStoreFileObject.cs | 48 + .../src/Generated/VectorStoreFileStatus.cs | 57 + .../Generated/VectorStoreFileStatusFilter.cs | 57 + .../src/Generated/VectorStoreFiles.cs | 635 +++++++++ .../src/Generated/VectorStoreObject.cs | 48 + ...icChunkingStrategyOptions.Serialization.cs | 150 +++ ...ectorStoreStaticChunkingStrategyOptions.cs | 87 ++ ...icChunkingStrategyRequest.Serialization.cs | 134 ++ ...ectorStoreStaticChunkingStrategyRequest.cs | 44 + ...cChunkingStrategyResponse.Serialization.cs | 134 ++ ...ctorStoreStaticChunkingStrategyResponse.cs | 44 + .../src/Generated/VectorStoreStatus.cs | 54 + .../src/Generated/VectorStores.cs | 720 ++++++++++ .../src/Properties/AssemblyInfo.cs | 11 + .../Azure.AI.Agents.Persistent.Tests.csproj | 20 + .../tsp-location.yaml | 4 + sdk/ai/ci.yml | 35 + 490 files changed, 61084 insertions(+) create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/Azure.AI.Agents.Persistent.sln create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/CHANGELOG.md create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/Directory.Build.props create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/README.md create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Azure.AI.Agents.Persistent.csproj create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AIAgentsPersistentClientBuilderExtensions.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AIAgentsPersistentModelFactory.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AISearchIndexResource.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AISearchIndexResource.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AgentsAdministrationClient.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AgentsAdministrationClientOptions.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchQueryType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchResource.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchResource.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBinding.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBinding.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBindingType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionStorageQueue.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionStorageQueue.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingCustomSearchToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingCustomSearchToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingGroundingToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingGroundingToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolResource.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolResource.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateAgentRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateAgentRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateMessageRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateMessageRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateRunRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateRunRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadAndRunRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadAndRunRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileBatchRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/DoneEvent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ErrorEvent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/File.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/File.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchRankingOptions.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchRankingOptions.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContentType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinitionDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolResource.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolResource.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileState.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Files.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionName.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionName.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ImageDetailLevel.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/IncompleteDetailsReason.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/IncompleteRunDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/IncompleteRunDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Argument.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/ChangeTrackingList.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/ModelSerializationExtensions.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/MultipartFormDataRequestContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Optional.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatus.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatusObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAzureFunctionDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAzureFunctionDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalCodeInterpreterToolCallDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatus.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatusObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponse.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponse.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponseObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFunctionDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFunctionDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageImageFileDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageImageFileDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFileCitationDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFileCitationDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFilePathDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFilePathDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRequiredFunctionToolCallDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRequiredFunctionToolCallDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRunStepFunctionToolCallDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRunStepFunctionToolCallDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalSubmitToolOutputsDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ListSortOrder.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageAttachment.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageAttachment.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageBlockType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageContent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDelta.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDelta.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunk.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunk.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunkObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaContent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContentObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextAnnotation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextAnnotation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContentObject.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContentObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotationObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotationObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationAnnotation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationAnnotation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileContent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileParam.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileParam.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageUrlParam.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageUrlParam.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetailsReason.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputContentBlock.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputContentBlock.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageFileBlock.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageFileBlock.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageUrlBlock.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageUrlBlock.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputTextBlock.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputTextBlock.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageRole.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageStreamEvent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextAnnotation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextAnnotation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextContent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFileCitationAnnotation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFilePathAnnotation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFilePathAnnotation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationAnnotation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationAnnotation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Messages.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MicrosoftFabricToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MicrosoftFabricToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ModifyVectorStoreRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ModifyVectorStoreRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFile.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFile.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFileObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFilePurpose.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThread.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThread.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThreadObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStep.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStep.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStepObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessage.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessage.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessageObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRun.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRun.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRunObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStore.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStore.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFile.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFile.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFileObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAnonymousAuthDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAnonymousAuthDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionAuthDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionAuthDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionSecurityScheme.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionSecurityScheme.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiFunctionDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiFunctionDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedAuthDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedAuthDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedSecurityScheme.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentStreamEvent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThread.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThread.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadCreationOptions.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadCreationOptions.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormat.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormat.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormatMode.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiToolChoiceOptionMode.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoice.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoice.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoiceType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredAction.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredAction.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredFunctionToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredFunctionToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormat.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchema.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchema.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaType.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaTypeType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunAdditionalFieldList.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunCompletionUsage.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunCompletionUsage.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunError.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunError.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStep.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStep.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepAzureAISearchToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepAzureAISearchToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepBingGroundingToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepBingGroundingToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageOutput.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageOutput.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageReference.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageReference.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterLogOutput.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterLogOutput.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCallOutput.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCompletionUsage.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCompletionUsage.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCustomSearchToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCustomSearchToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDelta.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDelta.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunk.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunk.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunkObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutput.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterLogOutput.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterOutput.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaDetail.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaDetail.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFileSearchToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunction.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunction.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunctionToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreationObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCallObject.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCallObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepError.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepError.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepErrorCode.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResult.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResult.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResults.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResults.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFunctionToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFunctionToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationReference.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationReference.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMicrosoftFabricToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMicrosoftFabricToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepOpenAPIToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepOpenAPIToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepSharepointToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepSharepointToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepStreamEvent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCallDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCallDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunSteps.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStreamEvent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Runs.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfiguration.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfiguration.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfigurationList.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfigurationList.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SharepointToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SharepointToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsAction.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsAction.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsToRunRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatus.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatusObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessage.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessage.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageOptions.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageOptions.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRun.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRun.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRunObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadStreamEvent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Threads.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnection.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnection.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnectionList.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnectionList.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolOutput.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolOutput.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolResources.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolResources.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationObject.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationStrategy.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageContent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaContent.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaContent.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaTextAnnotation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageInputContentBlock.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageInputContentBlock.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageTextAnnotation.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageTextAnnotation.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownOpenApiAuthDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownOpenApiAuthDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredAction.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredAction.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaDetail.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaDetail.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDetails.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDetails.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepToolCall.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyResponse.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateAgentRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateAgentRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateCodeInterpreterToolResourceOptions.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateFileSearchToolResourceOptions.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateMessageRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateMessageRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateRunRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateRunRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateThreadRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateThreadRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateToolResourcesOptions.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateToolResourcesOptions.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UploadFileRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UploadFileRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStore.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStore.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyResponse.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequestType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponse.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponseType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfiguration.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfiguration.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfigurations.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfigurations.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSource.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSource.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSourceAssetType.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatus.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatusObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicy.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicy.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicyAnchor.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFile.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFile.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatch.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatch.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatchObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatchStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatches.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileCount.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileCount.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatusObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileError.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileError.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileErrorCode.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileStatusFilter.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFiles.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreObject.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyOptions.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyRequest.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyResponse.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStatus.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStores.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/src/Properties/AssemblyInfo.cs create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/tests/Azure.AI.Agents.Persistent.Tests.csproj create mode 100644 sdk/ai/Azure.AI.Agents.Persistent/tsp-location.yaml create mode 100644 sdk/ai/ci.yml diff --git a/sdk/ai/Azure.AI.Agents.Persistent/Azure.AI.Agents.Persistent.sln b/sdk/ai/Azure.AI.Agents.Persistent/Azure.AI.Agents.Persistent.sln new file mode 100644 index 000000000000..de57a7dfc048 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/Azure.AI.Agents.Persistent.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +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 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Agents.Persistent", "src\Azure.AI.Agents.Persistent.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Agents.Persistent.Tests", "tests\Azure.AI.Agents.Persistent.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 + {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 + {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.Agents.Persistent/CHANGELOG.md b/sdk/ai/Azure.AI.Agents.Persistent/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Agents.Persistent/Directory.Build.props b/sdk/ai/Azure.AI.Agents.Persistent/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/ai/Azure.AI.Agents.Persistent/README.md b/sdk/ai/Azure.AI.Agents.Persistent/README.md new file mode 100644 index 000000000000..7bbf14933332 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/README.md @@ -0,0 +1,107 @@ +# Azure.AI.Agents.Persistent client library for .NET + +Azure.AI.Agents.Persistent is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Agents.Persistent/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.AI.Agents.Persistent --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> 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 + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +### Service API versions + +The client library targets the latest service API version by default. A client instance accepts an optional service API version parameter from its options to specify which API version service to communicate. + +#### Select a service API version + +You have the flexibility to explicitly select a supported service API version when instantiating a client by configuring its associated options. This ensures that the client can communicate with services using the specified API version. + +For example, + +```C# Snippet:CreateClientForSpecificApiVersion +Uri endpoint = new Uri(""); +DefaultAzureCredential credential = new DefaultAzureCredential(); +ClientOptions options = new ClientOptions(ClientOptions.ServiceVersion.) +var client = new Client(endpoint, credential, options); +``` + +When selecting an API version, it's important to verify that there are no breaking changes compared to the latest API version. If there are significant differences, API calls may fail due to incompatibility. + +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Agents.Persistent/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[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.Agents.Persistent/README.png) \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Azure.AI.Agents.Persistent.csproj b/sdk/ai/Azure.AI.Agents.Persistent/src/Azure.AI.Agents.Persistent.csproj new file mode 100644 index 000000000000..4a6d17091404 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Azure.AI.Agents.Persistent.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.AI.Agents.Persistent client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.AI.Agents.Persistent for Azure Data Plane + 1.0.0-beta.1 + Azure.AI.Agents.Persistent + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AIAgentsPersistentClientBuilderExtensions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AIAgentsPersistentClientBuilderExtensions.cs new file mode 100644 index 000000000000..6d32869cfc02 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AIAgentsPersistentClientBuilderExtensions.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.AI.Agents.Persistent; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AIAgentsPersistentClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// A credential used to authenticate to an Azure Service. + public static IAzureClientBuilder AddAgentsAdministrationClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new AgentsAdministrationClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + public static IAzureClientBuilder AddAgentsAdministrationClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new AgentsAdministrationClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddAgentsAdministrationClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AIAgentsPersistentModelFactory.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AIAgentsPersistentModelFactory.cs new file mode 100644 index 000000000000..e132b9a38a1d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AIAgentsPersistentModelFactory.cs @@ -0,0 +1,1160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// Model factory for models. + public static partial class AIAgentsPersistentModelFactory + { + /// Initializes a new instance of . + /// The type of binding, which is always 'storage_queue'. + /// Storage queue. + /// A new instance for mocking. + public static AzureFunctionBinding AzureFunctionBinding(AzureFunctionBindingType type = default, AzureFunctionStorageQueue storageQueue = null) + { + return new AzureFunctionBinding(type, storageQueue, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Type. + /// The JSON schema, describing response format. + /// A new instance for mocking. + public static ResponseFormatJsonSchemaType ResponseFormatJsonSchemaType(ResponseFormatJsonSchemaTypeType type = default, ResponseFormatJsonSchema jsonSchema = null) + { + return new ResponseFormatJsonSchemaType(type, jsonSchema, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always assistant. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The name of the agent. + /// The description of the agent. + /// The ID of the model to use. + /// The system instructions for the agent to use. + /// + /// The collection of tools enabled for the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The response format of the tool calls used by this agent. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// A new instance for mocking. + public static PersistentAgent PersistentAgent(string id = null, PersistentAgentObject @object = default, DateTimeOffset createdAt = default, string name = null, string description = null, string model = null, string instructions = null, IEnumerable tools = null, ToolResources toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null) + { + tools ??= new List(); + metadata ??= new Dictionary(); + + return new PersistentAgent( + id, + @object, + createdAt, + name, + description, + model, + instructions, + tools?.ToList(), + toolResources, + temperature, + topP, + responseFormat, + metadata, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The role of the entity that is creating the message. Allowed values include: + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). + /// + /// + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// A list of files attached to the message, and the tools they should be added to. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// A new instance for mocking. + public static ThreadMessageOptions ThreadMessageOptions(MessageRole role = default, BinaryData content = null, IEnumerable attachments = null, IDictionary metadata = null) + { + attachments ??= new List(); + metadata ??= new Dictionary(); + + return new ThreadMessageOptions(role, content, attachments?.ToList(), metadata, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The plain text content for this block. + /// A new instance for mocking. + public static MessageInputTextBlock MessageInputTextBlock(string text = null) + { + return new MessageInputTextBlock(MessageBlockType.Text, serializedAdditionalRawData: null, text); + } + + /// Initializes a new instance of . + /// Information about the referenced image file, including file ID and optional detail level. + /// A new instance for mocking. + public static MessageInputImageFileBlock MessageInputImageFileBlock(MessageImageFileParam imageFile = null) + { + return new MessageInputImageFileBlock(MessageBlockType.ImageFile, serializedAdditionalRawData: null, imageFile); + } + + /// Initializes a new instance of . + /// The ID of the previously uploaded image file. + /// Optional detail level for the image (auto, low, or high). + /// A new instance for mocking. + public static MessageImageFileParam MessageImageFileParam(string fileId = null, ImageDetailLevel? detail = null) + { + return new MessageImageFileParam(fileId, detail, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Information about the external image URL, including the URL and optional detail level. + /// A new instance for mocking. + public static MessageInputImageUrlBlock MessageInputImageUrlBlock(MessageImageUrlParam imageUrl = null) + { + return new MessageInputImageUrlBlock(MessageBlockType.ImageUrl, serializedAdditionalRawData: null, imageUrl); + } + + /// Initializes a new instance of . + /// The publicly accessible URL of the external image. + /// Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. + /// A new instance for mocking. + public static MessageImageUrlParam MessageImageUrlParam(string url = null, ImageDetailLevel? detail = null) + { + return new MessageImageUrlParam(url, detail, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'thread.run'. + /// The ID of the thread associated with this run. + /// The ID of the agent associated with the thread this run was performed against. + /// The status of the agent thread run. + /// + /// The details of the action required for the agent thread run to continue. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// The last error, if any, encountered by this agent thread run. + /// The ID of the model to use. + /// The overridden system instructions used for this agent thread run. + /// + /// The overridden enabled tools used for this agent thread run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + /// The Unix timestamp, in seconds, representing when this object was created. + /// The Unix timestamp, in seconds, representing when this item expires. + /// The Unix timestamp, in seconds, representing when this item was started. + /// The Unix timestamp, in seconds, representing when this completed. + /// The Unix timestamp, in seconds, representing when this was cancelled. + /// The Unix timestamp, in seconds, representing when this failed. + /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. + /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + /// The sampling temperature used for this run. If not set, defaults to 1. + /// The nucleus sampling value used for this run. If not set, defaults to 1. + /// The maximum number of prompt tokens specified to have been used over the course of the run. + /// The maximum number of completion tokens specified to have been used over the course of the run. + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// The response format of the tool calls used in this run. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. + /// Determines if tools can be executed in parallel within the run. + /// A new instance for mocking. + public static ThreadRun ThreadRun(string id = null, ThreadRunObject @object = default, string threadId = null, string assistantId = null, RunStatus status = default, RequiredAction requiredAction = null, RunError lastError = null, string model = null, string instructions = null, IEnumerable tools = null, DateTimeOffset createdAt = default, DateTimeOffset? expiresAt = null, DateTimeOffset? startedAt = null, DateTimeOffset? completedAt = null, DateTimeOffset? cancelledAt = null, DateTimeOffset? failedAt = null, IncompleteRunDetails incompleteDetails = null, RunCompletionUsage usage = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null, UpdateToolResourcesOptions toolResources = null, bool parallelToolCalls = default) + { + tools ??= new List(); + metadata ??= new Dictionary(); + + return new ThreadRun( + id, + @object, + threadId, + assistantId, + status, + requiredAction, + lastError, + model, + instructions, + tools?.ToList(), + createdAt, + expiresAt, + startedAt, + completedAt, + cancelledAt, + failedAt, + incompleteDetails, + usage, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, + metadata, + toolResources, + parallelToolCalls, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The object type for the required tool call. + /// The ID of the tool call. This ID must be referenced when submitting tool outputs. + /// A new instance for mocking. + public static RequiredToolCall RequiredToolCall(string type = null, string id = null) + { + return new UnknownRequiredToolCall(type, id, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The status for the error. + /// The human-readable text associated with the error. + /// A new instance for mocking. + public static RunError RunError(string code = null, string message = null) + { + return new RunError(code, message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The reason why the run is incomplete. This indicates which specific token limit was reached during the run. + /// A new instance for mocking. + public static IncompleteRunDetails IncompleteRunDetails(IncompleteDetailsReason reason = default) + { + return new IncompleteRunDetails(reason, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run. + /// Number of prompt tokens used over the course of the run. + /// Total number of tokens used (prompt + completion). + /// A new instance for mocking. + public static RunCompletionUsage RunCompletionUsage(long completionTokens = default, long promptTokens = default, long totalTokens = default) + { + return new RunCompletionUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'thread'. + /// The Unix timestamp, in seconds, representing when this object was created. + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type + /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list + /// of vector store IDs. + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// A new instance for mocking. + public static PersistentAgentThread PersistentAgentThread(string id = null, PersistentAgentThreadObject @object = default, DateTimeOffset createdAt = default, ToolResources toolResources = null, IReadOnlyDictionary metadata = null) + { + metadata ??= new Dictionary(); + + return new PersistentAgentThread( + id, + @object, + createdAt, + toolResources, + metadata, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'thread.message'. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The ID of the thread that this message belongs to. + /// The status of the message. + /// On an incomplete message, details about why the message is incomplete. + /// The Unix timestamp (in seconds) for when the message was completed. + /// The Unix timestamp (in seconds) for when the message was marked as incomplete. + /// The role associated with the agent thread message. + /// + /// The list of content items associated with the agent thread message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// If applicable, the ID of the agent that authored this message. + /// If applicable, the ID of the run associated with the authoring of this message. + /// A list of files attached to the message, and the tools they were added to. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// A new instance for mocking. + public static ThreadMessage ThreadMessage(string id = null, ThreadMessageObject @object = default, DateTimeOffset createdAt = default, string threadId = null, MessageStatus status = default, MessageIncompleteDetails incompleteDetails = null, DateTimeOffset? completedAt = null, DateTimeOffset? incompleteAt = null, MessageRole role = default, IEnumerable contentItems = null, string assistantId = null, string runId = null, IEnumerable attachments = null, IReadOnlyDictionary metadata = null) + { + contentItems ??= new List(); + attachments ??= new List(); + metadata ??= new Dictionary(); + + return new ThreadMessage( + id, + @object, + createdAt, + threadId, + status, + incompleteDetails, + completedAt, + incompleteAt, + role, + contentItems?.ToList(), + assistantId, + runId, + attachments?.ToList(), + metadata, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The provided reason describing why the message was marked as incomplete. + /// A new instance for mocking. + public static MessageIncompleteDetails MessageIncompleteDetails(MessageIncompleteDetailsReason reason = default) + { + return new MessageIncompleteDetails(reason, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The object type. + /// The textual content associated with this text annotation item. + /// A new instance for mocking. + public static MessageTextAnnotation MessageTextAnnotation(string type = null, string text = null) + { + return new UnknownMessageTextAnnotation(type, text, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The textual content associated with this text annotation item. + /// The details of the URL citation. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + /// A new instance for mocking. + public static MessageTextUrlCitationAnnotation MessageTextUrlCitationAnnotation(string text = null, MessageTextUrlCitationDetails urlCitation = null, int? startIndex = null, int? endIndex = null) + { + return new MessageTextUrlCitationAnnotation( + "url_citation", + text, + serializedAdditionalRawData: null, + urlCitation, + startIndex, + endIndex); + } + + /// Initializes a new instance of . + /// The URL associated with this citation. + /// The title of the URL. + /// A new instance for mocking. + public static MessageTextUrlCitationDetails MessageTextUrlCitationDetails(string url = null, string title = null) + { + return new MessageTextUrlCitationDetails(url, title, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'thread.run.step'. + /// The type of run step, which can be either message_creation or tool_calls. + /// The ID of the agent associated with the run step. + /// The ID of the thread that was run. + /// The ID of the run that this run step is a part of. + /// The status of this run step. + /// + /// The details for this run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// If applicable, information about the last error encountered by this run step. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The Unix timestamp, in seconds, representing when this item expired. + /// The Unix timestamp, in seconds, representing when this completed. + /// The Unix timestamp, in seconds, representing when this was cancelled. + /// The Unix timestamp, in seconds, representing when this failed. + /// Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// A new instance for mocking. + public static RunStep RunStep(string id = null, RunStepObject @object = default, RunStepType type = default, string assistantId = null, string threadId = null, string runId = null, RunStepStatus status = default, RunStepDetails stepDetails = null, RunStepError lastError = null, DateTimeOffset createdAt = default, DateTimeOffset? expiredAt = null, DateTimeOffset? completedAt = null, DateTimeOffset? cancelledAt = null, DateTimeOffset? failedAt = null, RunStepCompletionUsage usage = null, IReadOnlyDictionary metadata = null) + { + metadata ??= new Dictionary(); + + return new RunStep( + id, + @object, + type, + assistantId, + threadId, + runId, + status, + stepDetails, + lastError, + createdAt, + expiredAt, + completedAt, + cancelledAt, + failedAt, + usage, + metadata, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Information about the message creation associated with this run step. + /// A new instance for mocking. + public static RunStepMessageCreationDetails RunStepMessageCreationDetails(RunStepMessageCreationReference messageCreation = null) + { + return new RunStepMessageCreationDetails(RunStepType.MessageCreation, serializedAdditionalRawData: null, messageCreation); + } + + /// Initializes a new instance of . + /// The ID of the message created by this run step. + /// A new instance for mocking. + public static RunStepMessageCreationReference RunStepMessageCreationReference(string messageId = null) + { + return new RunStepMessageCreationReference(messageId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// A list of tool call details for this run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// A new instance for mocking. + public static RunStepToolCallDetails RunStepToolCallDetails(IEnumerable toolCalls = null) + { + toolCalls ??= new List(); + + return new RunStepToolCallDetails(RunStepType.ToolCalls, serializedAdditionalRawData: null, toolCalls?.ToList()); + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// A new instance for mocking. + public static RunStepToolCall RunStepToolCall(string type = null, string id = null) + { + return new UnknownRunStepToolCall(type, id, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// For now, this is always going to be an empty object. + /// A new instance for mocking. + public static RunStepFileSearchToolCall RunStepFileSearchToolCall(string id = null, RunStepFileSearchToolCallResults fileSearch = null) + { + return new RunStepFileSearchToolCall("file_search", id, serializedAdditionalRawData: null, fileSearch); + } + + /// Initializes a new instance of . + /// Ranking options for file search. + /// The array of a file search results. + /// A new instance for mocking. + public static RunStepFileSearchToolCallResults RunStepFileSearchToolCallResults(FileSearchRankingOptions rankingOptions = null, IEnumerable results = null) + { + results ??= new List(); + + return new RunStepFileSearchToolCallResults(rankingOptions, results?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The ID of the file that result was found in. + /// The name of the file that result was found in. + /// The score of the result. All values must be a floating point number between 0 and 1. + /// The content of the result that was found. The content is only included if requested via the include query parameter. + /// A new instance for mocking. + public static RunStepFileSearchToolCallResult RunStepFileSearchToolCallResult(string fileId = null, string fileName = null, float score = default, IEnumerable content = null) + { + content ??= new List(); + + return new RunStepFileSearchToolCallResult(fileId, fileName, score, content?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The type of the content. + /// The text content of the file. + /// A new instance for mocking. + public static FileSearchToolCallContent FileSearchToolCallContent(FileSearchToolCallContentType type = default, string text = null) + { + return new FileSearchToolCallContent(type, text, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepBingGroundingToolCall RunStepBingGroundingToolCall(string id = null, IReadOnlyDictionary bingGrounding = null) + { + bingGrounding ??= new Dictionary(); + + return new RunStepBingGroundingToolCall("bing_grounding", id, serializedAdditionalRawData: null, bingGrounding); + } + + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepAzureAISearchToolCall RunStepAzureAISearchToolCall(string id = null, IReadOnlyDictionary azureAISearch = null) + { + azureAISearch ??= new Dictionary(); + + return new RunStepAzureAISearchToolCall("azure_ai_search", id, serializedAdditionalRawData: null, azureAISearch); + } + + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepSharepointToolCall RunStepSharepointToolCall(string id = null, IReadOnlyDictionary sharePoint = null) + { + sharePoint ??= new Dictionary(); + + return new RunStepSharepointToolCall("sharepoint_grounding", id, serializedAdditionalRawData: null, sharePoint); + } + + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepMicrosoftFabricToolCall RunStepMicrosoftFabricToolCall(string id = null, IReadOnlyDictionary microsoftFabric = null) + { + microsoftFabric ??= new Dictionary(); + + return new RunStepMicrosoftFabricToolCall("fabric_dataagent", id, serializedAdditionalRawData: null, microsoftFabric); + } + + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepCustomSearchToolCall RunStepCustomSearchToolCall(string id = null, IReadOnlyDictionary bingCustomSearch = null) + { + bingCustomSearch ??= new Dictionary(); + + return new RunStepCustomSearchToolCall("bing_custom_search", id, serializedAdditionalRawData: null, bingCustomSearch); + } + + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepOpenAPIToolCall RunStepOpenAPIToolCall(string id = null, IReadOnlyDictionary openAPI = null) + { + openAPI ??= new Dictionary(); + + return new RunStepOpenAPIToolCall("openapi", id, serializedAdditionalRawData: null, openAPI); + } + + /// Initializes a new instance of . + /// The error code for this error. + /// The human-readable text associated with this error. + /// A new instance for mocking. + public static RunStepError RunStepError(RunStepErrorCode code = default, string message = null) + { + return new RunStepError(code, message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run step. + /// Number of prompt tokens used over the course of the run step. + /// Total number of tokens used (prompt + completion). + /// A new instance for mocking. + public static RunStepCompletionUsage RunStepCompletionUsage(long completionTokens = default, long promptTokens = default, long totalTokens = default) + { + return new RunStepCompletionUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The object type, which is always 'file'. + /// The identifier, which can be referenced in API endpoints. + /// The size of the file, in bytes. + /// The name of the file. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The intended purpose of a file. + /// The state of the file. This field is available in Azure OpenAI only. + /// The error message with details in case processing of this file failed. This field is available in Azure OpenAI only. + /// A new instance for mocking. + public static OpenAIFile OpenAIFile(OpenAIFileObject @object = default, string id = null, int size = default, string filename = null, DateTimeOffset createdAt = default, OpenAIFilePurpose purpose = default, FileState? status = null, string statusDetails = null) + { + return new OpenAIFile( + @object, + id, + size, + filename, + createdAt, + purpose, + status, + statusDetails, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The file data, in bytes. + /// The intended purpose of the uploaded file. Use `assistants` for Agents and Message files, `vision` for Agents image file inputs, `batch` for Batch API, and `fine-tune` for Fine-tuning. + /// The name of the file. + /// A new instance for mocking. + public static UploadFileRequest UploadFileRequest(File data = null, OpenAIFilePurpose purpose = default, string filename = null) + { + return new UploadFileRequest(data, purpose, filename, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The allowed media (MIME) types of the file contents. + /// + /// In file bodies, this value comes from the `Content-Type` header of the request or response. In JSON bodies, + /// this value is serialized as a field in the response. + /// + /// NOTE: this is not _necessarily_ the same as the `Content-Type` header of the request or response, but + /// it will be for file bodies. It may be different if the file is serialized as a JSON object. It always refers to the + /// _contents_ of the file, and not necessarily the way the file itself is transmitted or serialized. + /// + /// + /// The name of the file, if any. + /// + /// In file bodies, this value comes from the `filename` parameter of the `Content-Disposition` header of the response + /// or multipart payload. In JSON bodies, this value is serialized as a field in the response. + /// + /// NOTE: By default, `filename` cannot be sent in request payloads and can only be sent in responses and multipart + /// payloads, as the `Content-Disposition` header is not valid in requests. If you want to send the `filename` in a request, + /// you must extend the `File` model and override the `filename` property with a different location defined by HTTP metadata + /// decorators. + /// + /// + /// The contents of the file. + /// + /// In file bodies, this value comes from the body of the request, response, or multipart payload. In JSON bodies, + /// this value is serialized as a field in the response. + /// + /// A new instance for mocking. + public static File File(string contentType = null, string filename = null, BinaryData contents = null) + { + return new File(contentType, filename, contents, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// A new instance for mocking. + public static OpenAIPageableListOfVectorStore OpenAIPageableListOfVectorStore(OpenAIPageableListOfVectorStoreObject @object = default, IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = default) + { + data ??= new List(); + + return new OpenAIPageableListOfVectorStore( + @object, + data?.ToList(), + firstId, + lastId, + hasMore, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store`. + /// The Unix timestamp (in seconds) for when the vector store was created. + /// The name of the vector store. + /// The total number of bytes used by the files in the vector store. + /// Files count grouped by status processed or being processed by this vector store. + /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. + /// Details on when this vector store expires. + /// The Unix timestamp (in seconds) for when the vector store will expire. + /// The Unix timestamp (in seconds) for when the vector store was last active. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// A new instance for mocking. + public static VectorStore VectorStore(string id = null, VectorStoreObject @object = default, DateTimeOffset createdAt = default, string name = null, int usageBytes = default, VectorStoreFileCount fileCounts = null, VectorStoreStatus status = default, VectorStoreExpirationPolicy expiresAfter = null, DateTimeOffset? expiresAt = null, DateTimeOffset? lastActiveAt = null, IReadOnlyDictionary metadata = null) + { + metadata ??= new Dictionary(); + + return new VectorStore( + id, + @object, + createdAt, + name, + usageBytes, + fileCounts, + status, + expiresAfter, + expiresAt, + lastActiveAt, + metadata, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The number of files that are currently being processed. + /// The number of files that have been successfully processed. + /// The number of files that have failed to process. + /// The number of files that were cancelled. + /// The total number of files. + /// A new instance for mocking. + public static VectorStoreFileCount VectorStoreFileCount(int inProgress = default, int completed = default, int failed = default, int cancelled = default, int total = default) + { + return new VectorStoreFileCount( + inProgress, + completed, + failed, + cancelled, + total, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The options for the static chunking strategy. + /// A new instance for mocking. + public static VectorStoreStaticChunkingStrategyRequest VectorStoreStaticChunkingStrategyRequest(VectorStoreStaticChunkingStrategyOptions @static = null) + { + return new VectorStoreStaticChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType.Static, serializedAdditionalRawData: null, @static); + } + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// The object type, which is always 'vector_store.deleted'. + /// A new instance for mocking. + public static VectorStoreDeletionStatus VectorStoreDeletionStatus(string id = null, bool deleted = default, VectorStoreDeletionStatusObject @object = default) + { + return new VectorStoreDeletionStatus(id, deleted, @object, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// A new instance for mocking. + public static OpenAIPageableListOfVectorStoreFile OpenAIPageableListOfVectorStoreFile(OpenAIPageableListOfVectorStoreFileObject @object = default, IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = default) + { + data ??= new List(); + + return new OpenAIPageableListOfVectorStoreFile( + @object, + data?.ToList(), + firstId, + lastId, + hasMore, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store.file`. + /// + /// The total vector store usage in bytes. Note that this may be different from the original file + /// size. + /// + /// The Unix timestamp (in seconds) for when the vector store file was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. + /// The last error associated with this vector store file. Will be `null` if there are no errors. + /// + /// The strategy used to chunk the file. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A new instance for mocking. + public static VectorStoreFile VectorStoreFile(string id = null, VectorStoreFileObject @object = default, int usageBytes = default, DateTimeOffset createdAt = default, string vectorStoreId = null, VectorStoreFileStatus status = default, VectorStoreFileError lastError = null, VectorStoreChunkingStrategyResponse chunkingStrategy = null) + { + return new VectorStoreFile( + id, + @object, + usageBytes, + createdAt, + vectorStoreId, + status, + lastError, + chunkingStrategy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// One of `server_error` or `rate_limit_exceeded`. + /// A human-readable description of the error. + /// A new instance for mocking. + public static VectorStoreFileError VectorStoreFileError(VectorStoreFileErrorCode code = default, string message = null) + { + return new VectorStoreFileError(code, message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The options for the static chunking strategy. + /// A new instance for mocking. + public static VectorStoreStaticChunkingStrategyResponse VectorStoreStaticChunkingStrategyResponse(VectorStoreStaticChunkingStrategyOptions @static = null) + { + return new VectorStoreStaticChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType.Static, serializedAdditionalRawData: null, @static); + } + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// The object type, which is always 'vector_store.deleted'. + /// A new instance for mocking. + public static VectorStoreFileDeletionStatus VectorStoreFileDeletionStatus(string id = null, bool deleted = default, VectorStoreFileDeletionStatusObject @object = default) + { + return new VectorStoreFileDeletionStatus(id, deleted, @object, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store.file_batch`. + /// The Unix timestamp (in seconds) for when the vector store files batch was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. + /// Files count grouped by status processed or being processed by this vector store. + /// A new instance for mocking. + public static VectorStoreFileBatch VectorStoreFileBatch(string id = null, VectorStoreFileBatchObject @object = default, DateTimeOffset createdAt = default, string vectorStoreId = null, VectorStoreFileBatchStatus status = default, VectorStoreFileCount fileCounts = null) + { + return new VectorStoreFileBatch( + id, + @object, + createdAt, + vectorStoreId, + status, + fileCounts, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier of the message, which can be referenced in API endpoints. + /// The object type, which is always `thread.message.delta`. + /// The delta containing the fields that have changed on the Message. + /// A new instance for mocking. + public static MessageDeltaChunk MessageDeltaChunk(string id = null, MessageDeltaChunkObject @object = default, MessageDelta delta = null) + { + return new MessageDeltaChunk(id, @object, delta, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The entity that produced the message. + /// + /// The content of the message as an array of text and/or images. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A new instance for mocking. + public static MessageDelta MessageDelta(MessageRole role = default, IEnumerable content = null) + { + content ??= new List(); + + return new MessageDelta(role, content?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The type of content for this content part. + /// A new instance for mocking. + public static MessageDeltaContent MessageDeltaContent(int index = default, string type = null) + { + return new UnknownMessageDeltaContent(index, type, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The image_file data. + /// A new instance for mocking. + public static MessageDeltaImageFileContent MessageDeltaImageFileContent(int index = default, MessageDeltaImageFileContentObject imageFile = null) + { + return new MessageDeltaImageFileContent(index, "image_file", serializedAdditionalRawData: null, imageFile); + } + + /// Initializes a new instance of . + /// The file ID of the image in the message content. + /// A new instance for mocking. + public static MessageDeltaImageFileContentObject MessageDeltaImageFileContentObject(string fileId = null) + { + return new MessageDeltaImageFileContentObject(fileId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The text content details. + /// A new instance for mocking. + public static MessageDeltaTextContent MessageDeltaTextContent(int index = default, MessageDeltaTextContentObject text = null) + { + return new MessageDeltaTextContent(index, "text", serializedAdditionalRawData: null, text); + } + + /// Initializes a new instance of . + /// The data that makes up the text. + /// + /// Annotations for the text. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// A new instance for mocking. + public static MessageDeltaTextContentObject MessageDeltaTextContentObject(string value = null, IEnumerable annotations = null) + { + annotations ??= new List(); + + return new MessageDeltaTextContentObject(value, annotations?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// A new instance for mocking. + public static MessageDeltaTextAnnotation MessageDeltaTextAnnotation(int index = default, string type = null) + { + return new UnknownMessageDeltaTextAnnotation(index, type, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The details of the URL citation. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + /// A new instance for mocking. + public static MessageDeltaTextUrlCitationAnnotation MessageDeltaTextUrlCitationAnnotation(int index = default, MessageDeltaTextUrlCitationDetails urlCitation = null, int? startIndex = null, int? endIndex = null) + { + return new MessageDeltaTextUrlCitationAnnotation( + index, + "url_citation", + serializedAdditionalRawData: null, + urlCitation, + startIndex, + endIndex); + } + + /// Initializes a new instance of . + /// The URL associated with this citation. + /// The title of the URL. + /// A new instance for mocking. + public static MessageDeltaTextUrlCitationDetails MessageDeltaTextUrlCitationDetails(string url = null, string title = null) + { + return new MessageDeltaTextUrlCitationDetails(url, title, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The file citation information. + /// The text in the message content that needs to be replaced. + /// The start index of this annotation in the content text. + /// The end index of this annotation in the content text. + /// A new instance for mocking. + public static MessageDeltaTextFileCitationAnnotation MessageDeltaTextFileCitationAnnotation(int index = default, MessageDeltaTextFileCitationAnnotationObject fileCitation = null, string text = null, int? startIndex = null, int? endIndex = null) + { + return new MessageDeltaTextFileCitationAnnotation( + index, + "file_citation", + serializedAdditionalRawData: null, + fileCitation, + text, + startIndex, + endIndex); + } + + /// Initializes a new instance of . + /// The ID of the specific file the citation is from. + /// The specific quote in the cited file. + /// A new instance for mocking. + public static MessageDeltaTextFileCitationAnnotationObject MessageDeltaTextFileCitationAnnotationObject(string fileId = null, string quote = null) + { + return new MessageDeltaTextFileCitationAnnotationObject(fileId, quote, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The file path information. + /// The start index of this annotation in the content text. + /// The end index of this annotation in the content text. + /// The text in the message content that needs to be replaced. + /// A new instance for mocking. + public static MessageDeltaTextFilePathAnnotation MessageDeltaTextFilePathAnnotation(int index = default, MessageDeltaTextFilePathAnnotationObject filePath = null, int? startIndex = null, int? endIndex = null, string text = null) + { + return new MessageDeltaTextFilePathAnnotation( + index, + "file_path", + serializedAdditionalRawData: null, + filePath, + startIndex, + endIndex, + text); + } + + /// Initializes a new instance of . + /// The file ID for the annotation. + /// A new instance for mocking. + public static MessageDeltaTextFilePathAnnotationObject MessageDeltaTextFilePathAnnotationObject(string fileId = null) + { + return new MessageDeltaTextFilePathAnnotationObject(fileId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier of the run step, which can be referenced in API endpoints. + /// The object type, which is always `thread.run.step.delta`. + /// The delta containing the fields that have changed on the run step. + /// A new instance for mocking. + public static RunStepDeltaChunk RunStepDeltaChunk(string id = null, RunStepDeltaChunkObject @object = default, RunStepDelta delta = null) + { + return new RunStepDeltaChunk(id, @object, delta, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The details of the run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A new instance for mocking. + public static RunStepDelta RunStepDelta(RunStepDeltaDetail stepDetails = null) + { + return new RunStepDelta(stepDetails, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The message creation data. + /// A new instance for mocking. + public static RunStepDeltaMessageCreation RunStepDeltaMessageCreation(RunStepDeltaMessageCreationObject messageCreation = null) + { + return new RunStepDeltaMessageCreation("message_creation", serializedAdditionalRawData: null, messageCreation); + } + + /// Initializes a new instance of . + /// The ID of the newly-created message. + /// A new instance for mocking. + public static RunStepDeltaMessageCreationObject RunStepDeltaMessageCreationObject(string messageId = null) + { + return new RunStepDeltaMessageCreationObject(messageId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The collection of tool calls for the tool call detail item. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// A new instance for mocking. + public static RunStepDeltaToolCallObject RunStepDeltaToolCallObject(IEnumerable toolCalls = null) + { + toolCalls ??= new List(); + + return new RunStepDeltaToolCallObject("tool_calls", serializedAdditionalRawData: null, toolCalls?.ToList()); + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// A new instance for mocking. + public static RunStepDeltaToolCall RunStepDeltaToolCall(int index = default, string id = null, string type = null) + { + return new UnknownRunStepDeltaToolCall(index, id, type, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The function data for the tool call. + /// A new instance for mocking. + public static RunStepDeltaFunctionToolCall RunStepDeltaFunctionToolCall(int index = default, string id = null, RunStepDeltaFunction function = null) + { + return new RunStepDeltaFunctionToolCall(index, id, "function", serializedAdditionalRawData: null, function); + } + + /// Initializes a new instance of . + /// The name of the function. + /// The arguments passed to the function as input. + /// The output of the function, null if outputs have not yet been submitted. + /// A new instance for mocking. + public static RunStepDeltaFunction RunStepDeltaFunction(string name = null, string arguments = null, string output = null) + { + return new RunStepDeltaFunction(name, arguments, output, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepDeltaFileSearchToolCall RunStepDeltaFileSearchToolCall(int index = default, string id = null, RunStepFileSearchToolCallResults fileSearch = null) + { + return new RunStepDeltaFileSearchToolCall(index, id, "file_search", serializedAdditionalRawData: null, fileSearch); + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The Code Interpreter data for the tool call. + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterToolCall RunStepDeltaCodeInterpreterToolCall(int index = default, string id = null, RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter = null) + { + return new RunStepDeltaCodeInterpreterToolCall(index, id, "code_interpreter", serializedAdditionalRawData: null, codeInterpreter); + } + + /// Initializes a new instance of . + /// The input into the Code Interpreter tool call. + /// + /// The outputs from the Code Interpreter tool call. Code Interpreter can output one or more + /// items, including text (`logs`) or images (`image`). Each of these are represented by a + /// different object type. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterDetailItemObject RunStepDeltaCodeInterpreterDetailItemObject(string input = null, IEnumerable outputs = null) + { + outputs ??= new List(); + + return new RunStepDeltaCodeInterpreterDetailItemObject(input, outputs?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The type of the streaming run step tool call's Code Interpreter output. + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterOutput RunStepDeltaCodeInterpreterOutput(int index = default, string type = null) + { + return new UnknownRunStepDeltaCodeInterpreterOutput(index, type, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The text output from the Code Interpreter tool call. + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterLogOutput RunStepDeltaCodeInterpreterLogOutput(int index = default, string logs = null) + { + return new RunStepDeltaCodeInterpreterLogOutput(index, "logs", serializedAdditionalRawData: null, logs); + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The image data for the Code Interpreter tool call output. + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterImageOutput RunStepDeltaCodeInterpreterImageOutput(int index = default, RunStepDeltaCodeInterpreterImageOutputObject image = null) + { + return new RunStepDeltaCodeInterpreterImageOutput(index, "image", serializedAdditionalRawData: null, image); + } + + /// Initializes a new instance of . + /// The file ID for the image. + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterImageOutputObject RunStepDeltaCodeInterpreterImageOutputObject(string fileId = null) + { + return new RunStepDeltaCodeInterpreterImageOutputObject(fileId, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AISearchIndexResource.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AISearchIndexResource.Serialization.cs new file mode 100644 index 000000000000..aa1282c94b61 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AISearchIndexResource.Serialization.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class AISearchIndexResource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var 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."); + } + + writer.WritePropertyName("index_connection_id"u8); + writer.WriteStringValue(IndexConnectionId); + 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 (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AISearchIndexResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AISearchIndexResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAISearchIndexResource(document.RootElement, options); + } + + internal static AISearchIndexResource DeserializeAISearchIndexResource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string indexConnectionId = default; + string indexName = default; + AzureAISearchQueryType? queryType = default; + int? topK = default; + string filter = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index_connection_id"u8)) + { + indexConnectionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("index_name"u8)) + { + indexName = property.Value.GetString(); + continue; + } + if (property.NameEquals("query_type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + queryType = new AzureAISearchQueryType(property.Value.GetString()); + continue; + } + if (property.NameEquals("top_k"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + topK = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("filter"u8)) + { + filter = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AISearchIndexResource( + indexConnectionId, + indexName, + queryType, + topK, + filter, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AISearchIndexResource)} does not support writing '{options.Format}' format."); + } + } + + AISearchIndexResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAISearchIndexResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AISearchIndexResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AISearchIndexResource FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAISearchIndexResource(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AISearchIndexResource.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AISearchIndexResource.cs new file mode 100644 index 000000000000..01a796b1e166 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AISearchIndexResource.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A AI Search Index resource. + public partial class AISearchIndexResource + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// 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. + /// or is null. + public AISearchIndexResource(string indexConnectionId, string indexName) + { + Argument.AssertNotNull(indexConnectionId, nameof(indexConnectionId)); + Argument.AssertNotNull(indexName, nameof(indexName)); + + IndexConnectionId = indexConnectionId; + IndexName = indexName; + } + + /// 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. + /// Odata filter string for search resource. + /// Keeps track of any properties unknown to the library. + internal AISearchIndexResource(string indexConnectionId, string indexName, AzureAISearchQueryType? queryType, int? topK, string filter, IDictionary serializedAdditionalRawData) + { + IndexConnectionId = indexConnectionId; + IndexName = indexName; + QueryType = queryType; + TopK = topK; + Filter = filter; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AISearchIndexResource() + { + } + + /// An index connection id in an IndexResource attached to this agent. + public string IndexConnectionId { 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; } + /// Odata filter string for search resource. + public string Filter { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AgentsAdministrationClient.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AgentsAdministrationClient.cs new file mode 100644 index 000000000000..eef847e1a8be --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AgentsAdministrationClient.cs @@ -0,0 +1,1138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Agents.Persistent +{ + // Data plane generated client. + /// The AgentsAdministration service client. + public partial class AgentsAdministrationClient + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of AgentsAdministrationClient for mocking. + protected AgentsAdministrationClient() + { + } + + /// Initializes a new instance of AgentsAdministrationClient. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public AgentsAdministrationClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AgentsAdministrationClientOptions()) + { + } + + /// Initializes a new instance of AgentsAdministrationClient. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public AgentsAdministrationClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AgentsAdministrationClientOptions()) + { + } + + /// Initializes a new instance of AgentsAdministrationClient. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AgentsAdministrationClient(Uri endpoint, AzureKeyCredential credential, AgentsAdministrationClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AgentsAdministrationClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader, AuthorizationApiKeyPrefix) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// Initializes a new instance of AgentsAdministrationClient. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AgentsAdministrationClient(Uri endpoint, TokenCredential credential, AgentsAdministrationClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AgentsAdministrationClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// Creates a new agent. + /// The ID of the model to use. + /// The name of the new agent. + /// The description of the new agent. + /// The system instructions for the new agent to use. + /// The collection of tools to enable for the new agent. + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The response format of the tool calls used by this agent. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// is null. + public virtual async Task> CreateAgentAsync(string model, string name = null, string description = null, string instructions = null, IEnumerable tools = null, ToolResources toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(model, nameof(model)); + + CreateAgentRequest createAgentRequest = new CreateAgentRequest( + model, + name, + description, + instructions, + tools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + toolResources, + temperature, + topP, + responseFormat, + metadata ?? new ChangeTrackingDictionary(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateAgentAsync(createAgentRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(PersistentAgent.FromResponse(response), response); + } + + /// Creates a new agent. + /// The ID of the model to use. + /// The name of the new agent. + /// The description of the new agent. + /// The system instructions for the new agent to use. + /// The collection of tools to enable for the new agent. + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The response format of the tool calls used by this agent. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// is null. + public virtual Response CreateAgent(string model, string name = null, string description = null, string instructions = null, IEnumerable tools = null, ToolResources toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(model, nameof(model)); + + CreateAgentRequest createAgentRequest = new CreateAgentRequest( + model, + name, + description, + instructions, + tools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + toolResources, + temperature, + topP, + responseFormat, + metadata ?? new ChangeTrackingDictionary(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateAgent(createAgentRequest.ToRequestContent(), context); + return Response.FromValue(PersistentAgent.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new agent. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, 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 CreateAgentAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.CreateAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateAgentRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new agent. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, 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 Response CreateAgent(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.CreateAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateAgentRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of agents that were previously created. + /// 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 to use. + internal virtual async Task> InternalGetAgentsAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalGetAgentsAsync(limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfAgent.FromResponse(response), response); + } + + /// Gets a list of agents that were previously created. + /// 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 to use. + internal virtual Response InternalGetAgents(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalGetAgents(limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfAgent.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of agents that were previously created. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual async Task InternalGetAgentsAsync(int? limit, string order, string after, string before, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.InternalGetAgents"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetAgentsRequest(limit, order, after, before, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a list of agents that were previously created. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual Response InternalGetAgents(int? limit, string order, string after, string before, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.InternalGetAgents"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetAgentsRequest(limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves an existing agent. + /// Identifier of the agent. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAgentAsync(string assistantId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAgentAsync(assistantId, context).ConfigureAwait(false); + return Response.FromValue(PersistentAgent.FromResponse(response), response); + } + + /// Retrieves an existing agent. + /// Identifier of the agent. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetAgent(string assistantId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAgent(assistantId, context); + return Response.FromValue(PersistentAgent.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves an existing agent. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the agent. + /// The request context, 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 GetAgentAsync(string assistantId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.GetAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAgentRequest(assistantId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves an existing agent. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the agent. + /// The request context, 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 Response GetAgent(string assistantId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.GetAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAgentRequest(assistantId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Modifies an existing agent. + /// The ID of the agent to modify. + /// The ID of the model to use. + /// The modified name for the agent to use. + /// The modified description for the agent to use. + /// The modified system instructions for the new agent to use. + /// The modified collection of tools to enable for the agent. + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, + /// the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The response format of the tool calls used by this agent. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> UpdateAgentAsync(string assistantId, string model = null, string name = null, string description = null, string instructions = null, IEnumerable tools = null, ToolResources toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + UpdateAgentRequest updateAgentRequest = new UpdateAgentRequest( + model, + name, + description, + instructions, + tools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + toolResources, + temperature, + topP, + responseFormat, + metadata ?? new ChangeTrackingDictionary(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UpdateAgentAsync(assistantId, updateAgentRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(PersistentAgent.FromResponse(response), response); + } + + /// Modifies an existing agent. + /// The ID of the agent to modify. + /// The ID of the model to use. + /// The modified name for the agent to use. + /// The modified description for the agent to use. + /// The modified system instructions for the new agent to use. + /// The modified collection of tools to enable for the agent. + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, + /// the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The response format of the tool calls used by this agent. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response UpdateAgent(string assistantId, string model = null, string name = null, string description = null, string instructions = null, IEnumerable tools = null, ToolResources toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + UpdateAgentRequest updateAgentRequest = new UpdateAgentRequest( + model, + name, + description, + instructions, + tools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + toolResources, + temperature, + topP, + responseFormat, + metadata ?? new ChangeTrackingDictionary(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UpdateAgent(assistantId, updateAgentRequest.ToRequestContent(), context); + return Response.FromValue(PersistentAgent.FromResponse(response), response); + } + + /// + /// [Protocol Method] Modifies an existing agent. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the agent to modify. + /// The content to send as the body of the request. + /// The request context, 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 UpdateAgentAsync(string assistantId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.UpdateAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateAgentRequest(assistantId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Modifies an existing agent. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the agent to modify. + /// The content to send as the body of the request. + /// The request context, 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 Response UpdateAgent(string assistantId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.UpdateAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateAgentRequest(assistantId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes an agent. + /// Identifier of the agent. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalDeleteAgentAsync(string assistantId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalDeleteAgentAsync(assistantId, context).ConfigureAwait(false); + return Response.FromValue(InternalAgentDeletionStatus.FromResponse(response), response); + } + + /// Deletes an agent. + /// Identifier of the agent. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response InternalDeleteAgent(string assistantId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalDeleteAgent(assistantId, context); + return Response.FromValue(InternalAgentDeletionStatus.FromResponse(response), response); + } + + /// + /// [Protocol Method] Deletes an agent. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the agent. + /// The request context, 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. + internal virtual async Task InternalDeleteAgentAsync(string assistantId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.InternalDeleteAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalDeleteAgentRequest(assistantId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Deletes an agent. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the agent. + /// The request context, 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. + internal virtual Response InternalDeleteAgent(string assistantId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.InternalDeleteAgent"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalDeleteAgentRequest(assistantId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates a new agent thread and immediately starts a run using that new thread. + /// The ID of the agent for which the thread should be created. + /// The details used to create the new thread. If no thread is provided, an empty one will be created. + /// The overridden model that the agent should use to run the thread. + /// The overridden system instructions the agent should use to run the thread. + /// The overridden list of enabled tools the agent should use to run the thread. + /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens + /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// Specifies the format that the model must output. + /// If `true` functions will run in parallel during tool use. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// is null. + public virtual async Task> CreateThreadAndRunAsync(string assistantId, PersistentAgentThreadCreationOptions thread = null, string overrideModelName = null, string overrideInstructions = null, IEnumerable overrideTools = null, UpdateToolResourcesOptions toolResources = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(assistantId, nameof(assistantId)); + + CreateThreadAndRunRequest createThreadAndRunRequest = new CreateThreadAndRunRequest( + assistantId, + thread, + overrideModelName, + overrideInstructions, + overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + toolResources, + stream, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, + parallelToolCalls, + metadata ?? new ChangeTrackingDictionary(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateThreadAndRunAsync(createThreadAndRunRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Creates a new agent thread and immediately starts a run using that new thread. + /// The ID of the agent for which the thread should be created. + /// The details used to create the new thread. If no thread is provided, an empty one will be created. + /// The overridden model that the agent should use to run the thread. + /// The overridden system instructions the agent should use to run the thread. + /// The overridden list of enabled tools the agent should use to run the thread. + /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens + /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// Specifies the format that the model must output. + /// If `true` functions will run in parallel during tool use. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// is null. + public virtual Response CreateThreadAndRun(string assistantId, PersistentAgentThreadCreationOptions thread = null, string overrideModelName = null, string overrideInstructions = null, IEnumerable overrideTools = null, UpdateToolResourcesOptions toolResources = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(assistantId, nameof(assistantId)); + + CreateThreadAndRunRequest createThreadAndRunRequest = new CreateThreadAndRunRequest( + assistantId, + thread, + overrideModelName, + overrideInstructions, + overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + toolResources, + stream, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, + parallelToolCalls, + metadata ?? new ChangeTrackingDictionary(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateThreadAndRun(createThreadAndRunRequest.ToRequestContent(), context); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new agent thread and immediately starts a run using that new thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, 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 CreateThreadAndRunAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.CreateThreadAndRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateThreadAndRunRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new agent thread and immediately starts a run using that new thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, 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 Response CreateThreadAndRun(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AgentsAdministrationClient.CreateThreadAndRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateThreadAndRunRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + private Threads _cachedThreads; + private Messages _cachedMessages; + private Runs _cachedRuns; + private RunSteps _cachedRunSteps; + private Files _cachedFiles; + private VectorStores _cachedVectorStores; + private VectorStoreFiles _cachedVectorStoreFiles; + private VectorStoreFileBatches _cachedVectorStoreFileBatches; + + /// Initializes a new instance of Threads. + public virtual Threads GetThreadsClient() + { + return Volatile.Read(ref _cachedThreads) ?? Interlocked.CompareExchange(ref _cachedThreads, new Threads(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, _apiVersion), null) ?? _cachedThreads; + } + + /// Initializes a new instance of Messages. + public virtual Messages GetMessagesClient() + { + return Volatile.Read(ref _cachedMessages) ?? Interlocked.CompareExchange(ref _cachedMessages, new Messages(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, _apiVersion), null) ?? _cachedMessages; + } + + /// Initializes a new instance of Runs. + public virtual Runs GetRunsClient() + { + return Volatile.Read(ref _cachedRuns) ?? Interlocked.CompareExchange(ref _cachedRuns, new Runs(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, _apiVersion), null) ?? _cachedRuns; + } + + /// Initializes a new instance of RunSteps. + public virtual RunSteps GetRunStepsClient() + { + return Volatile.Read(ref _cachedRunSteps) ?? Interlocked.CompareExchange(ref _cachedRunSteps, new RunSteps(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, _apiVersion), null) ?? _cachedRunSteps; + } + + /// Initializes a new instance of Files. + public virtual Files GetFilesClient() + { + return Volatile.Read(ref _cachedFiles) ?? Interlocked.CompareExchange(ref _cachedFiles, new Files(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, _apiVersion), null) ?? _cachedFiles; + } + + /// Initializes a new instance of VectorStores. + public virtual VectorStores GetVectorStoresClient() + { + return Volatile.Read(ref _cachedVectorStores) ?? Interlocked.CompareExchange(ref _cachedVectorStores, new VectorStores(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, _apiVersion), null) ?? _cachedVectorStores; + } + + /// Initializes a new instance of VectorStoreFiles. + public virtual VectorStoreFiles GetVectorStoreFilesClient() + { + return Volatile.Read(ref _cachedVectorStoreFiles) ?? Interlocked.CompareExchange(ref _cachedVectorStoreFiles, new VectorStoreFiles(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, _apiVersion), null) ?? _cachedVectorStoreFiles; + } + + /// Initializes a new instance of VectorStoreFileBatches. + public virtual VectorStoreFileBatches GetVectorStoreFileBatchesClient() + { + return Volatile.Read(ref _cachedVectorStoreFileBatches) ?? Interlocked.CompareExchange(ref _cachedVectorStoreFileBatches, new VectorStoreFileBatches(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint, _apiVersion), null) ?? _cachedVectorStoreFileBatches; + } + + internal HttpMessage CreateCreateAgentRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/assistants", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalGetAgentsRequest(int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/assistants", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetAgentRequest(string assistantId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/assistants/", false); + uri.AppendPath(assistantId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUpdateAgentRequest(string assistantId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/assistants/", false); + uri.AppendPath(assistantId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalDeleteAgentRequest(string assistantId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/assistants/", false); + uri.AppendPath(assistantId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateThreadAndRunRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AgentsAdministrationClientOptions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AgentsAdministrationClientOptions.cs new file mode 100644 index 000000000000..721237fd271f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AgentsAdministrationClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + /// Client options for AgentsAdministrationClient. + public partial class AgentsAdministrationClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2025_05_15_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2025-05-15-preview". + V2025_05_15_Preview = 1, + } + + internal string Version { get; } + + /// Initializes new instance of AgentsAdministrationClientOptions. + public AgentsAdministrationClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2025_05_15_Preview => "2025-05-15-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchQueryType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchQueryType.cs new file mode 100644 index 000000000000..3a147da2e2ae --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchQueryType.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Available query types for Azure AI Search tool. + public readonly partial struct AzureAISearchQueryType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureAISearchQueryType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SimpleValue = "simple"; + private const string SemanticValue = "semantic"; + private const string VectorValue = "vector"; + private const string VectorSimpleHybridValue = "vector_simple_hybrid"; + private const string VectorSemanticHybridValue = "vector_semantic_hybrid"; + + /// 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. + public static bool operator ==(AzureAISearchQueryType left, AzureAISearchQueryType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureAISearchQueryType left, AzureAISearchQueryType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureAISearchQueryType(string value) => 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.Agents.Persistent/src/Generated/AzureAISearchResource.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchResource.Serialization.cs new file mode 100644 index 000000000000..c6a408ead617 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchResource.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class AzureAISearchResource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchResource)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(IndexList)) + { + writer.WritePropertyName("indexes"u8); + writer.WriteStartArray(); + foreach (var item in IndexList) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AzureAISearchResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAISearchResource(document.RootElement, options); + } + + internal static AzureAISearchResource DeserializeAzureAISearchResource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList indexes = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("indexes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AISearchIndexResource.DeserializeAISearchIndexResource(item, options)); + } + indexes = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureAISearchResource(indexes ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AzureAISearchResource)} does not support writing '{options.Format}' format."); + } + } + + AzureAISearchResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureAISearchResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAISearchResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AzureAISearchResource FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureAISearchResource(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchResource.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchResource.cs new file mode 100644 index 000000000000..1c8d009cbb4e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchResource.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A set of index resources used by the `azure_ai_search` tool. + public partial class AzureAISearchResource + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public AzureAISearchResource() + { + IndexList = new ChangeTrackingList(); + } + + /// 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 AzureAISearchResource(IList indexList, IDictionary serializedAdditionalRawData) + { + IndexList = indexList; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The indices attached to this agent. There can be a maximum of 1 index + /// resource attached to the agent. + /// + public IList IndexList { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchToolDefinition.Serialization.cs new file mode 100644 index 000000000000..8371e0d16839 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchToolDefinition.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class AzureAISearchToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + AzureAISearchToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAISearchToolDefinition(document.RootElement, options); + } + + internal static AzureAISearchToolDefinition DeserializeAzureAISearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureAISearchToolDefinition(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AzureAISearchToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + AzureAISearchToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureAISearchToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAISearchToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new AzureAISearchToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureAISearchToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchToolDefinition.cs new file mode 100644 index 000000000000..4e3f44492aad --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureAISearchToolDefinition.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for an Azure AI search tool as used to configure an agent. + public partial class AzureAISearchToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + public AzureAISearchToolDefinition() + { + Type = "azure_ai_search"; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal AzureAISearchToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBinding.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBinding.Serialization.cs new file mode 100644 index 000000000000..7463d73864cf --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBinding.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class AzureFunctionBinding : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var 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.ToString()); + writer.WritePropertyName("storage_queue"u8); + writer.WriteObjectValue(StorageQueue, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AzureFunctionBinding IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionBinding(document.RootElement, options); + } + + internal static AzureFunctionBinding DeserializeAzureFunctionBinding(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AzureFunctionBindingType type = default; + AzureFunctionStorageQueue storageQueue = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new AzureFunctionBindingType(property.Value.GetString()); + continue; + } + if (property.NameEquals("storage_queue"u8)) + { + storageQueue = AzureFunctionStorageQueue.DeserializeAzureFunctionStorageQueue(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureFunctionBinding(type, storageQueue, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support writing '{options.Format}' format."); + } + } + + AzureFunctionBinding IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureFunctionBinding(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AzureFunctionBinding FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureFunctionBinding(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBinding.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBinding.cs new file mode 100644 index 000000000000..7cc1a5a7cfd4 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBinding.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The structure for keeping storage queue name and URI. + public partial class AzureFunctionBinding + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// 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(AzureFunctionBindingType type, AzureFunctionStorageQueue storageQueue, IDictionary serializedAdditionalRawData) + { + Type = type; + StorageQueue = storageQueue; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AzureFunctionBinding() + { + } + + /// The type of binding, which is always 'storage_queue'. + public AzureFunctionBindingType Type { get; } = AzureFunctionBindingType.StorageQueue; + + /// Storage queue. + public AzureFunctionStorageQueue StorageQueue { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBindingType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBindingType.cs new file mode 100644 index 000000000000..7c123058e5aa --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionBindingType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The AzureFunctionBinding_type. + public readonly partial struct AzureFunctionBindingType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureFunctionBindingType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string StorageQueueValue = "storage_queue"; + + /// storage_queue. + public static AzureFunctionBindingType StorageQueue { get; } = new AzureFunctionBindingType(StorageQueueValue); + /// Determines if two values are the same. + public static bool operator ==(AzureFunctionBindingType left, AzureFunctionBindingType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureFunctionBindingType left, AzureFunctionBindingType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureFunctionBindingType(string value) => new AzureFunctionBindingType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureFunctionBindingType other && Equals(other); + /// + public bool Equals(AzureFunctionBindingType 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.Agents.Persistent/src/Generated/AzureFunctionStorageQueue.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionStorageQueue.Serialization.cs new file mode 100644 index 000000000000..ef6e147973d1 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionStorageQueue.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class AzureFunctionStorageQueue : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var 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(StorageServiceEndpoint); + writer.WritePropertyName("queue_name"u8); + writer.WriteStringValue(QueueName); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AzureFunctionStorageQueue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionStorageQueue(document.RootElement, options); + } + + internal static AzureFunctionStorageQueue DeserializeAzureFunctionStorageQueue(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string queueServiceEndpoint = default; + string queueName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("queue_service_endpoint"u8)) + { + queueServiceEndpoint = property.Value.GetString(); + continue; + } + if (property.NameEquals("queue_name"u8)) + { + queueName = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureFunctionStorageQueue(queueServiceEndpoint, queueName, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support writing '{options.Format}' format."); + } + } + + AzureFunctionStorageQueue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureFunctionStorageQueue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AzureFunctionStorageQueue FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureFunctionStorageQueue(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionStorageQueue.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionStorageQueue.cs new file mode 100644 index 000000000000..6e0515c5d320 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionStorageQueue.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The structure for keeping storage queue name and URI. + public partial class AzureFunctionStorageQueue + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// 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 storageServiceEndpoint, string queueName) + { + Argument.AssertNotNull(storageServiceEndpoint, nameof(storageServiceEndpoint)); + Argument.AssertNotNull(queueName, nameof(queueName)); + + StorageServiceEndpoint = storageServiceEndpoint; + 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 storageServiceEndpoint, string queueName, IDictionary serializedAdditionalRawData) + { + StorageServiceEndpoint = storageServiceEndpoint; + QueueName = queueName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AzureFunctionStorageQueue() + { + } + + /// URI to the Azure Storage Queue service allowing you to manipulate a queue. + public string StorageServiceEndpoint { get; set; } + /// The name of an Azure function storage queue. + public string QueueName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionToolDefinition.Serialization.cs new file mode 100644 index 000000000000..14afc89b261f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionToolDefinition.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class AzureFunctionToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("azure_function"u8); + writer.WriteObjectValue(InternalAzureFunction, options); + } + + AzureFunctionToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionToolDefinition(document.RootElement, options); + } + + internal static AzureFunctionToolDefinition DeserializeAzureFunctionToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalAzureFunctionDefinition azureFunction = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("azure_function"u8)) + { + azureFunction = InternalAzureFunctionDefinition.DeserializeInternalAzureFunctionDefinition(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AzureFunctionToolDefinition(type, serializedAdditionalRawData, azureFunction); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AzureFunctionToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + AzureFunctionToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureFunctionToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new AzureFunctionToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAzureFunctionToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionToolDefinition.cs new file mode 100644 index 000000000000..0b30c14d86e3 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/AzureFunctionToolDefinition.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for a azure function tool as used to configure an agent. + public partial class AzureFunctionToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + /// The definition of the concrete function that the function tool should call. + /// is null. + public AzureFunctionToolDefinition(InternalAzureFunctionDefinition internalAzureFunction) + { + Argument.AssertNotNull(internalAzureFunction, nameof(internalAzureFunction)); + + Type = "azure_function"; + InternalAzureFunction = internalAzureFunction; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The definition of the concrete function that the function tool should call. + internal AzureFunctionToolDefinition(string type, IDictionary serializedAdditionalRawData, InternalAzureFunctionDefinition internalAzureFunction) : base(type, serializedAdditionalRawData) + { + InternalAzureFunction = internalAzureFunction; + } + + /// Initializes a new instance of for deserialization. + internal AzureFunctionToolDefinition() + { + } + + /// The definition of the concrete function that the function tool should call. + public InternalAzureFunctionDefinition InternalAzureFunction { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingCustomSearchToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingCustomSearchToolDefinition.Serialization.cs new file mode 100644 index 000000000000..d427e97543f9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingCustomSearchToolDefinition.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class BingCustomSearchToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("bing_custom_search"u8); + writer.WriteObjectValue(BingCustomSearch, options); + } + + BingCustomSearchToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingCustomSearchToolDefinition(document.RootElement, options); + } + + internal static BingCustomSearchToolDefinition DeserializeBingCustomSearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SearchConfigurationList bingCustomSearch = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("bing_custom_search"u8)) + { + bingCustomSearch = SearchConfigurationList.DeserializeSearchConfigurationList(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BingCustomSearchToolDefinition(type, serializedAdditionalRawData, bingCustomSearch); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BingCustomSearchToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + BingCustomSearchToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBingCustomSearchToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingCustomSearchToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new BingCustomSearchToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBingCustomSearchToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingCustomSearchToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingCustomSearchToolDefinition.cs new file mode 100644 index 000000000000..4988f226e07b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingCustomSearchToolDefinition.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for a Bing custom search tool as used to configure an agent. + public partial class BingCustomSearchToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + /// The list of search configurations used by the bing custom search tool. + /// is null. + public BingCustomSearchToolDefinition(SearchConfigurationList bingCustomSearch) + { + Argument.AssertNotNull(bingCustomSearch, nameof(bingCustomSearch)); + + Type = "bing_custom_search"; + BingCustomSearch = bingCustomSearch; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The list of search configurations used by the bing custom search tool. + internal BingCustomSearchToolDefinition(string type, IDictionary serializedAdditionalRawData, SearchConfigurationList bingCustomSearch) : base(type, serializedAdditionalRawData) + { + BingCustomSearch = bingCustomSearch; + } + + /// Initializes a new instance of for deserialization. + internal BingCustomSearchToolDefinition() + { + } + + /// The list of search configurations used by the bing custom search tool. + public SearchConfigurationList BingCustomSearch { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingGroundingToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingGroundingToolDefinition.Serialization.cs new file mode 100644 index 000000000000..48b94715494c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingGroundingToolDefinition.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class BingGroundingToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("bing_grounding"u8); + writer.WriteObjectValue(BingGrounding, options); + } + + BingGroundingToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingGroundingToolDefinition(document.RootElement, options); + } + + internal static BingGroundingToolDefinition DeserializeBingGroundingToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolConnectionList bingGrounding = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("bing_grounding"u8)) + { + bingGrounding = ToolConnectionList.DeserializeToolConnectionList(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BingGroundingToolDefinition(type, serializedAdditionalRawData, bingGrounding); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(BingGroundingToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + BingGroundingToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBingGroundingToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingGroundingToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new BingGroundingToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBingGroundingToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingGroundingToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingGroundingToolDefinition.cs new file mode 100644 index 000000000000..1e6a8d3f844b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/BingGroundingToolDefinition.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for a bing grounding search tool as used to configure an agent. + public partial class BingGroundingToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + /// The list of connections used by the bing grounding tool. + /// is null. + public BingGroundingToolDefinition(ToolConnectionList bingGrounding) + { + Argument.AssertNotNull(bingGrounding, nameof(bingGrounding)); + + Type = "bing_grounding"; + BingGrounding = bingGrounding; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The list of connections used by the bing grounding tool. + internal BingGroundingToolDefinition(string type, IDictionary serializedAdditionalRawData, ToolConnectionList bingGrounding) : base(type, serializedAdditionalRawData) + { + BingGrounding = bingGrounding; + } + + /// Initializes a new instance of for deserialization. + internal BingGroundingToolDefinition() + { + } + + /// The list of connections used by the bing grounding tool. + public ToolConnectionList BingGrounding { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolDefinition.Serialization.cs new file mode 100644 index 000000000000..f4a74e151f75 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolDefinition.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class CodeInterpreterToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + CodeInterpreterToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCodeInterpreterToolDefinition(document.RootElement, options); + } + + internal static CodeInterpreterToolDefinition DeserializeCodeInterpreterToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CodeInterpreterToolDefinition(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + CodeInterpreterToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCodeInterpreterToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new CodeInterpreterToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCodeInterpreterToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolDefinition.cs new file mode 100644 index 000000000000..1bb115a36f9c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolDefinition.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for a code interpreter tool as used to configure an agent. + public partial class CodeInterpreterToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + public CodeInterpreterToolDefinition() + { + Type = "code_interpreter"; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal CodeInterpreterToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolResource.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolResource.Serialization.cs new file mode 100644 index 000000000000..417af9a1176d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolResource.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class CodeInterpreterToolResource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeInterpreterToolResource)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(DataSources)) + { + writer.WritePropertyName("data_sources"u8); + writer.WriteStartArray(); + foreach (var item in DataSources) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CodeInterpreterToolResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeInterpreterToolResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCodeInterpreterToolResource(document.RootElement, options); + } + + internal static CodeInterpreterToolResource DeserializeCodeInterpreterToolResource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + IList dataSources = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (property.NameEquals("data_sources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VectorStoreDataSource.DeserializeVectorStoreDataSource(item, options)); + } + dataSources = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CodeInterpreterToolResource(fileIds ?? new ChangeTrackingList(), dataSources ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolResource)} does not support writing '{options.Format}' format."); + } + } + + CodeInterpreterToolResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCodeInterpreterToolResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CodeInterpreterToolResource FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCodeInterpreterToolResource(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolResource.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolResource.cs new file mode 100644 index 000000000000..faaba7dc05ec --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CodeInterpreterToolResource.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A set of resources that are used by the `code_interpreter` tool. + public partial class CodeInterpreterToolResource + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public CodeInterpreterToolResource() + { + FileIds = new ChangeTrackingList(); + DataSources = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + /// The data sources to be used. This option is mutually exclusive with the `fileIds` property. + /// Keeps track of any properties unknown to the library. + internal CodeInterpreterToolResource(IList fileIds, IList dataSources, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + DataSources = dataSources; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + public IList FileIds { get; } + /// The data sources to be used. This option is mutually exclusive with the `fileIds` property. + public IList DataSources { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentDetails.Serialization.cs new file mode 100644 index 000000000000..e8112c95246d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentDetails.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ConnectedAgentDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedAgentDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ConnectedAgentDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedAgentDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedAgentDetails(document.RootElement, options); + } + + internal static ConnectedAgentDetails DeserializeConnectedAgentDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string name = default; + string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedAgentDetails(id, name, description, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedAgentDetails)} does not support writing '{options.Format}' format."); + } + } + + ConnectedAgentDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeConnectedAgentDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedAgentDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ConnectedAgentDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeConnectedAgentDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentDetails.cs new file mode 100644 index 000000000000..857c3be16de9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentDetails.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Information for connecting one agent to another as a tool. + public partial class ConnectedAgentDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier of the child agent. + /// The name of the agent to be called. + /// A description of what the agent does, used by the model to choose when and how to call the agent. + /// , or is null. + public ConnectedAgentDetails(string id, string name, string description) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(description, nameof(description)); + + Id = id; + Name = name; + Description = description; + } + + /// Initializes a new instance of . + /// The identifier of the child agent. + /// The name of the agent to be called. + /// A description of what the agent does, used by the model to choose when and how to call the agent. + /// Keeps track of any properties unknown to the library. + internal ConnectedAgentDetails(string id, string name, string description, IDictionary serializedAdditionalRawData) + { + Id = id; + Name = name; + Description = description; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ConnectedAgentDetails() + { + } + + /// The identifier of the child agent. + public string Id { get; set; } + /// The name of the agent to be called. + public string Name { get; set; } + /// A description of what the agent does, used by the model to choose when and how to call the agent. + public string Description { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentToolDefinition.Serialization.cs new file mode 100644 index 000000000000..c9721b147cf5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentToolDefinition.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ConnectedAgentToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedAgentToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("connected_agent"u8); + writer.WriteObjectValue(ConnectedAgent, options); + } + + ConnectedAgentToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ConnectedAgentToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectedAgentToolDefinition(document.RootElement, options); + } + + internal static ConnectedAgentToolDefinition DeserializeConnectedAgentToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ConnectedAgentDetails connectedAgent = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connected_agent"u8)) + { + connectedAgent = ConnectedAgentDetails.DeserializeConnectedAgentDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ConnectedAgentToolDefinition(type, serializedAdditionalRawData, connectedAgent); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ConnectedAgentToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + ConnectedAgentToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeConnectedAgentToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectedAgentToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new ConnectedAgentToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeConnectedAgentToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentToolDefinition.cs new file mode 100644 index 000000000000..b92b9106ffd7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ConnectedAgentToolDefinition.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for a connected agent tool which defines a domain specific sub-agent. + public partial class ConnectedAgentToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + /// The sub-agent to connect. + /// is null. + public ConnectedAgentToolDefinition(ConnectedAgentDetails connectedAgent) + { + Argument.AssertNotNull(connectedAgent, nameof(connectedAgent)); + + Type = "connected_agent"; + ConnectedAgent = connectedAgent; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The sub-agent to connect. + internal ConnectedAgentToolDefinition(string type, IDictionary serializedAdditionalRawData, ConnectedAgentDetails connectedAgent) : base(type, serializedAdditionalRawData) + { + ConnectedAgent = connectedAgent; + } + + /// Initializes a new instance of for deserialization. + internal ConnectedAgentToolDefinition() + { + } + + /// The sub-agent to connect. + public ConnectedAgentDetails ConnectedAgent { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateAgentRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateAgentRequest.Serialization.cs new file mode 100644 index 000000000000..fdb152048e7f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateAgentRequest.Serialization.cs @@ -0,0 +1,379 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class CreateAgentRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateAgentRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + if (Optional.IsDefined(Name)) + { + if (Name != null) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + else + { + writer.WriteNull("name"); + } + } + if (Optional.IsDefined(Description)) + { + if (Description != null) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + else + { + writer.WriteNull("description"); + } + } + if (Optional.IsDefined(Instructions)) + { + if (Instructions != null) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); + } + else + { + writer.WriteNull("instructions"); + } + } + if (Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + } + if (Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); + } + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateAgentRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateAgentRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateAgentRequest(document.RootElement, options); + } + + internal static CreateAgentRequest DeserializeCreateAgentRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string model = default; + string name = default; + string description = default; + string instructions = default; + IReadOnlyList tools = default; + ToolResources toolResources = default; + float? temperature = default; + float? topP = default; + BinaryData responseFormat = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + name = null; + continue; + } + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + description = null; + continue; + } + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + instructions = null; + continue; + } + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); + } + tools = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; + } + responseFormat = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateAgentRequest( + model, + name, + description, + instructions, + tools ?? new ChangeTrackingList(), + toolResources, + temperature, + topP, + responseFormat, + metadata ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateAgentRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateAgentRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateAgentRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateAgentRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateAgentRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateAgentRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateAgentRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateAgentRequest.cs new file mode 100644 index 000000000000..7d0f13930b79 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateAgentRequest.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The CreateAgentRequest. + internal partial class CreateAgentRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the model to use. + /// is null. + internal CreateAgentRequest(string model) + { + Argument.AssertNotNull(model, nameof(model)); + + Model = model; + Tools = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The ID of the model to use. + /// The name of the new agent. + /// The description of the new agent. + /// The system instructions for the new agent to use. + /// + /// The collection of tools to enable for the new agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The response format of the tool calls used by this agent. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal CreateAgentRequest(string model, string name, string description, string instructions, IReadOnlyList tools, ToolResources toolResources, float? temperature, float? topP, BinaryData responseFormat, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Model = model; + Name = name; + Description = description; + Instructions = instructions; + Tools = tools; + ToolResources = toolResources; + Temperature = temperature; + TopP = topP; + ResponseFormat = responseFormat; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateAgentRequest() + { + } + + /// The ID of the model to use. + public string Model { get; } + /// The name of the new agent. + public string Name { get; } + /// The description of the new agent. + public string Description { get; } + /// The system instructions for the new agent to use. + public string Instructions { get; } + /// + /// The collection of tools to enable for the new agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + public IReadOnlyList Tools { get; } + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + public ToolResources ToolResources { 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. + /// + 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; } + /// + /// The response format of the tool calls used by this agent. + /// + /// 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 ResponseFormat { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateMessageRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateMessageRequest.Serialization.cs new file mode 100644 index 000000000000..a4642bfa3160 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateMessageRequest.Serialization.cs @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class CreateMessageRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (Optional.IsCollectionDefined(Attachments)) + { + if (Attachments != null) + { + writer.WritePropertyName("attachments"u8); + writer.WriteStartArray(); + foreach (var item in Attachments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("attachments"); + } + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateMessageRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateMessageRequest(document.RootElement, options); + } + + internal static CreateMessageRequest DeserializeCreateMessageRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageRole role = default; + BinaryData content = default; + IReadOnlyList attachments = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("role"u8)) + { + role = new MessageRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + content = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("attachments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageAttachment.DeserializeMessageAttachment(item, options)); + } + attachments = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateMessageRequest(role, content, attachments ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateMessageRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateMessageRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateMessageRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateMessageRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateMessageRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateMessageRequest.cs new file mode 100644 index 000000000000..dcb3895bb858 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateMessageRequest.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The CreateMessageRequest. + internal partial class CreateMessageRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// The role of the entity that is creating the message. Allowed values include: + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). + /// + /// + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// is null. + internal CreateMessageRequest(MessageRole role, BinaryData content) + { + Argument.AssertNotNull(content, nameof(content)); + + Role = role; + Content = content; + Attachments = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// The role of the entity that is creating the message. Allowed values include: + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). + /// + /// + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// A list of files attached to the message, and the tools they should be added to. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal CreateMessageRequest(MessageRole role, BinaryData content, IReadOnlyList attachments, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Role = role; + Content = content; + Attachments = attachments; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateMessageRequest() + { + } + + /// + /// The role of the entity that is creating the message. Allowed values include: + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). + /// + public MessageRole Role { get; } + /// + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// 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; } + /// A list of files attached to the message, and the tools they should be added to. + public IReadOnlyList Attachments { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateRunRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateRunRequest.Serialization.cs new file mode 100644 index 000000000000..c217cfd15933 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateRunRequest.Serialization.cs @@ -0,0 +1,530 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class CreateRunRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateRunRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("assistant_id"u8); + writer.WriteStringValue(AssistantId); + if (Optional.IsDefined(OverrideModelName)) + { + if (OverrideModelName != null) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(OverrideModelName); + } + else + { + writer.WriteNull("model"); + } + } + if (Optional.IsDefined(OverrideInstructions)) + { + if (OverrideInstructions != null) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(OverrideInstructions); + } + else + { + writer.WriteNull("instructions"); + } + } + if (Optional.IsDefined(AdditionalInstructions)) + { + if (AdditionalInstructions != null) + { + writer.WritePropertyName("additional_instructions"u8); + writer.WriteStringValue(AdditionalInstructions); + } + else + { + writer.WriteNull("additional_instructions"); + } + } + if (Optional.IsCollectionDefined(AdditionalMessages)) + { + if (AdditionalMessages != null) + { + writer.WritePropertyName("additional_messages"u8); + writer.WriteStartArray(); + foreach (var item in AdditionalMessages) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("additional_messages"); + } + } + if (Optional.IsCollectionDefined(OverrideTools)) + { + if (OverrideTools != null) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in OverrideTools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("tools"); + } + } + if (Optional.IsDefined(Stream)) + { + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); + } + if (Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (Optional.IsDefined(MaxPromptTokens)) + { + if (MaxPromptTokens != null) + { + writer.WritePropertyName("max_prompt_tokens"u8); + writer.WriteNumberValue(MaxPromptTokens.Value); + } + else + { + writer.WriteNull("max_prompt_tokens"); + } + } + if (Optional.IsDefined(MaxCompletionTokens)) + { + if (MaxCompletionTokens != null) + { + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxCompletionTokens.Value); + } + else + { + writer.WriteNull("max_completion_tokens"); + } + } + if (Optional.IsDefined(TruncationStrategy)) + { + if (TruncationStrategy != null) + { + writer.WritePropertyName("truncation_strategy"u8); + writer.WriteObjectValue(TruncationStrategy, options); + } + else + { + writer.WriteNull("truncation_strategy"); + } + } + if (Optional.IsDefined(ToolChoice)) + { + if (ToolChoice != null) + { + writer.WritePropertyName("tool_choice"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ToolChoice); +#else + using (JsonDocument document = JsonDocument.Parse(ToolChoice, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("tool_choice"); + } + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); + } + } + if (Optional.IsDefined(ParallelToolCalls)) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCalls.Value); + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateRunRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateRunRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateRunRequest(document.RootElement, options); + } + + internal static CreateRunRequest DeserializeCreateRunRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string assistantId = default; + string model = default; + string instructions = default; + string additionalInstructions = default; + IReadOnlyList additionalMessages = default; + IReadOnlyList tools = default; + bool? stream = default; + float? temperature = default; + float? topP = default; + int? maxPromptTokens = default; + int? maxCompletionTokens = default; + TruncationObject truncationStrategy = default; + BinaryData toolChoice = default; + BinaryData responseFormat = default; + bool? parallelToolCalls = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("assistant_id"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("model"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + model = null; + continue; + } + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + instructions = null; + continue; + } + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("additional_instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + additionalInstructions = null; + continue; + } + additionalInstructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("additional_messages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ThreadMessageOptions.DeserializeThreadMessageOptions(item, options)); + } + additionalMessages = array; + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); + } + tools = array; + continue; + } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stream = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("max_prompt_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxPromptTokens = null; + continue; + } + maxPromptTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_completion_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxCompletionTokens = null; + continue; + } + maxCompletionTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("truncation_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + truncationStrategy = null; + continue; + } + truncationStrategy = TruncationObject.DeserializeTruncationObject(property.Value, options); + continue; + } + if (property.NameEquals("tool_choice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolChoice = null; + continue; + } + toolChoice = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; + } + responseFormat = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("parallel_tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parallelToolCalls = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateRunRequest( + assistantId, + model, + instructions, + additionalInstructions, + additionalMessages ?? new ChangeTrackingList(), + tools ?? new ChangeTrackingList(), + stream, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, + parallelToolCalls, + metadata ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateRunRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateRunRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateRunRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateRunRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateRunRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateRunRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateRunRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateRunRequest.cs new file mode 100644 index 000000000000..d7133a726db5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateRunRequest.cs @@ -0,0 +1,281 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The CreateRunRequest. + internal partial class CreateRunRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the agent that should run the thread. + /// is null. + internal CreateRunRequest(string assistantId) + { + Argument.AssertNotNull(assistantId, nameof(assistantId)); + + AssistantId = assistantId; + AdditionalMessages = new ChangeTrackingList(); + OverrideTools = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The ID of the agent that should run the thread. + /// The overridden model name that the agent should use to run the thread. + /// The overridden system instructions that the agent should use to run the thread. + /// + /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior + /// on a per-run basis without overriding other instructions. + /// + /// Adds additional messages to the thread before creating the run. + /// + /// The overridden list of enabled tools that the agent should use to run the thread. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort + /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// Specifies the format that the model must output. + /// If `true` functions will run in parallel during tool use. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal CreateRunRequest(string assistantId, string overrideModelName, string overrideInstructions, string additionalInstructions, IReadOnlyList additionalMessages, IReadOnlyList overrideTools, bool? stream, float? temperature, float? topP, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, bool? parallelToolCalls, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + AssistantId = assistantId; + OverrideModelName = overrideModelName; + OverrideInstructions = overrideInstructions; + AdditionalInstructions = additionalInstructions; + AdditionalMessages = additionalMessages; + OverrideTools = overrideTools; + Stream = stream; + Temperature = temperature; + TopP = topP; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolChoice = toolChoice; + ResponseFormat = responseFormat; + ParallelToolCalls = parallelToolCalls; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateRunRequest() + { + } + + /// The ID of the agent that should run the thread. + public string AssistantId { get; } + /// The overridden model name that the agent should use to run the thread. + public string OverrideModelName { get; } + /// The overridden system instructions that the agent should use to run the thread. + public string OverrideInstructions { get; } + /// + /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior + /// on a per-run basis without overriding other instructions. + /// + public string AdditionalInstructions { get; } + /// Adds additional messages to the thread before creating the run. + public IReadOnlyList AdditionalMessages { get; } + /// + /// The overridden list of enabled tools that the agent should use to run the thread. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + public IReadOnlyList OverrideTools { get; } + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + public bool? Stream { 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. + /// + 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; } + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + public int? MaxPromptTokens { get; } + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort + /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + public int? MaxCompletionTokens { get; } + /// The strategy to use for dropping messages as the context windows moves forward. + public TruncationObject TruncationStrategy { get; } + /// + /// Controls whether or not and which tool is called by the model. + /// + /// 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; } + /// + /// Specifies the format that the model must output. + /// + /// 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 ResponseFormat { get; } + /// If `true` functions will run in parallel during tool use. + public bool? ParallelToolCalls { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadAndRunRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadAndRunRequest.Serialization.cs new file mode 100644 index 000000000000..3d5a67a997f0 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadAndRunRequest.Serialization.cs @@ -0,0 +1,513 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class CreateThreadAndRunRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateThreadAndRunRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("assistant_id"u8); + writer.WriteStringValue(AssistantId); + if (Optional.IsDefined(Thread)) + { + writer.WritePropertyName("thread"u8); + writer.WriteObjectValue(Thread, options); + } + if (Optional.IsDefined(OverrideModelName)) + { + if (OverrideModelName != null) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(OverrideModelName); + } + else + { + writer.WriteNull("model"); + } + } + if (Optional.IsDefined(OverrideInstructions)) + { + if (OverrideInstructions != null) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(OverrideInstructions); + } + else + { + writer.WriteNull("instructions"); + } + } + if (Optional.IsCollectionDefined(OverrideTools)) + { + if (OverrideTools != null) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in OverrideTools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("tools"); + } + } + if (Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + } + if (Optional.IsDefined(Stream)) + { + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); + } + if (Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (Optional.IsDefined(MaxPromptTokens)) + { + if (MaxPromptTokens != null) + { + writer.WritePropertyName("max_prompt_tokens"u8); + writer.WriteNumberValue(MaxPromptTokens.Value); + } + else + { + writer.WriteNull("max_prompt_tokens"); + } + } + if (Optional.IsDefined(MaxCompletionTokens)) + { + if (MaxCompletionTokens != null) + { + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxCompletionTokens.Value); + } + else + { + writer.WriteNull("max_completion_tokens"); + } + } + if (Optional.IsDefined(TruncationStrategy)) + { + if (TruncationStrategy != null) + { + writer.WritePropertyName("truncation_strategy"u8); + writer.WriteObjectValue(TruncationStrategy, options); + } + else + { + writer.WriteNull("truncation_strategy"); + } + } + if (Optional.IsDefined(ToolChoice)) + { + if (ToolChoice != null) + { + writer.WritePropertyName("tool_choice"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ToolChoice); +#else + using (JsonDocument document = JsonDocument.Parse(ToolChoice, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("tool_choice"); + } + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); + } + } + if (Optional.IsDefined(ParallelToolCalls)) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCalls.Value); + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateThreadAndRunRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateThreadAndRunRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateThreadAndRunRequest(document.RootElement, options); + } + + internal static CreateThreadAndRunRequest DeserializeCreateThreadAndRunRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string assistantId = default; + PersistentAgentThreadCreationOptions thread = default; + string model = default; + string instructions = default; + IReadOnlyList tools = default; + UpdateToolResourcesOptions toolResources = default; + bool? stream = default; + float? temperature = default; + float? topP = default; + int? maxPromptTokens = default; + int? maxCompletionTokens = default; + TruncationObject truncationStrategy = default; + BinaryData toolChoice = default; + BinaryData responseFormat = default; + bool? parallelToolCalls = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("assistant_id"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("thread"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + thread = PersistentAgentThreadCreationOptions.DeserializePersistentAgentThreadCreationOptions(property.Value, options); + continue; + } + if (property.NameEquals("model"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + model = null; + continue; + } + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + instructions = null; + continue; + } + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); + } + tools = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = UpdateToolResourcesOptions.DeserializeUpdateToolResourcesOptions(property.Value, options); + continue; + } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stream = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("max_prompt_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxPromptTokens = null; + continue; + } + maxPromptTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_completion_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxCompletionTokens = null; + continue; + } + maxCompletionTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("truncation_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + truncationStrategy = null; + continue; + } + truncationStrategy = TruncationObject.DeserializeTruncationObject(property.Value, options); + continue; + } + if (property.NameEquals("tool_choice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolChoice = null; + continue; + } + toolChoice = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; + } + responseFormat = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("parallel_tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + parallelToolCalls = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateThreadAndRunRequest( + assistantId, + thread, + model, + instructions, + tools ?? new ChangeTrackingList(), + toolResources, + stream, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, + parallelToolCalls, + metadata ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateThreadAndRunRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateThreadAndRunRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateThreadAndRunRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateThreadAndRunRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateThreadAndRunRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateThreadAndRunRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadAndRunRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadAndRunRequest.cs new file mode 100644 index 000000000000..dfc360287213 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadAndRunRequest.cs @@ -0,0 +1,274 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The CreateThreadAndRunRequest. + internal partial class CreateThreadAndRunRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the agent for which the thread should be created. + /// is null. + internal CreateThreadAndRunRequest(string assistantId) + { + Argument.AssertNotNull(assistantId, nameof(assistantId)); + + AssistantId = assistantId; + OverrideTools = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The ID of the agent for which the thread should be created. + /// The details used to create the new thread. If no thread is provided, an empty one will be created. + /// The overridden model that the agent should use to run the thread. + /// The overridden system instructions the agent should use to run the thread. + /// + /// The overridden list of enabled tools the agent should use to run the thread. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens + /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// Specifies the format that the model must output. + /// If `true` functions will run in parallel during tool use. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal CreateThreadAndRunRequest(string assistantId, PersistentAgentThreadCreationOptions thread, string overrideModelName, string overrideInstructions, IReadOnlyList overrideTools, UpdateToolResourcesOptions toolResources, bool? stream, float? temperature, float? topP, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, bool? parallelToolCalls, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + AssistantId = assistantId; + Thread = thread; + OverrideModelName = overrideModelName; + OverrideInstructions = overrideInstructions; + OverrideTools = overrideTools; + ToolResources = toolResources; + Stream = stream; + Temperature = temperature; + TopP = topP; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolChoice = toolChoice; + ResponseFormat = responseFormat; + ParallelToolCalls = parallelToolCalls; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateThreadAndRunRequest() + { + } + + /// The ID of the agent for which the thread should be created. + public string AssistantId { get; } + /// The details used to create the new thread. If no thread is provided, an empty one will be created. + public PersistentAgentThreadCreationOptions Thread { get; } + /// The overridden model that the agent should use to run the thread. + public string OverrideModelName { get; } + /// The overridden system instructions the agent should use to run the thread. + public string OverrideInstructions { get; } + /// + /// The overridden list of enabled tools the agent should use to run the thread. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + public IReadOnlyList OverrideTools { get; } + /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. + public UpdateToolResourcesOptions ToolResources { get; } + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + public bool? Stream { 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. + /// + 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; } + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + public int? MaxPromptTokens { get; } + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens + /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + public int? MaxCompletionTokens { get; } + /// The strategy to use for dropping messages as the context windows moves forward. + public TruncationObject TruncationStrategy { get; } + /// + /// Controls whether or not and which tool is called by the model. + /// + /// 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; } + /// + /// Specifies the format that the model must output. + /// + /// 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 ResponseFormat { get; } + /// If `true` functions will run in parallel during tool use. + public bool? ParallelToolCalls { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadRequest.Serialization.cs new file mode 100644 index 000000000000..fb15ae93700f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadRequest.Serialization.cs @@ -0,0 +1,215 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class CreateThreadRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateThreadRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Messages)) + { + writer.WritePropertyName("messages"u8); + writer.WriteStartArray(); + foreach (var item in Messages) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateThreadRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateThreadRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateThreadRequest(document.RootElement, options); + } + + internal static CreateThreadRequest DeserializeCreateThreadRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList messages = default; + ToolResources toolResources = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ThreadMessageOptions.DeserializeThreadMessageOptions(item, options)); + } + messages = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateThreadRequest(messages ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateThreadRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateThreadRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateThreadRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateThreadRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateThreadRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateThreadRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadRequest.cs new file mode 100644 index 000000000000..f5e4e17d5c03 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateThreadRequest.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The CreateThreadRequest. + internal partial class CreateThreadRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal CreateThreadRequest() + { + Messages = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The initial messages to associate with the new thread. + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs. + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal CreateThreadRequest(IReadOnlyList messages, ToolResources toolResources, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Messages = messages; + ToolResources = toolResources; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The initial messages to associate with the new thread. + public IReadOnlyList Messages { get; } + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs. + /// + public ToolResources ToolResources { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs new file mode 100644 index 000000000000..1da2add20c3f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class CreateVectorStoreFileBatchRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateVectorStoreFileBatchRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(DataSources)) + { + writer.WritePropertyName("data_sources"u8); + writer.WriteStartArray(); + foreach (var item in DataSources) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateVectorStoreFileBatchRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateVectorStoreFileBatchRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateVectorStoreFileBatchRequest(document.RootElement, options); + } + + internal static CreateVectorStoreFileBatchRequest DeserializeCreateVectorStoreFileBatchRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList fileIds = default; + IReadOnlyList dataSources = default; + VectorStoreChunkingStrategyRequest chunkingStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (property.NameEquals("data_sources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VectorStoreDataSource.DeserializeVectorStoreDataSource(item, options)); + } + dataSources = array; + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + chunkingStrategy = VectorStoreChunkingStrategyRequest.DeserializeVectorStoreChunkingStrategyRequest(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateVectorStoreFileBatchRequest(fileIds ?? new ChangeTrackingList(), dataSources ?? new ChangeTrackingList(), chunkingStrategy, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateVectorStoreFileBatchRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateVectorStoreFileBatchRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateVectorStoreFileBatchRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateVectorStoreFileBatchRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateVectorStoreFileBatchRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateVectorStoreFileBatchRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileBatchRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileBatchRequest.cs new file mode 100644 index 000000000000..5169668b712d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileBatchRequest.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The CreateVectorStoreFileBatchRequest. + internal partial class CreateVectorStoreFileBatchRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal CreateVectorStoreFileBatchRequest() + { + FileIds = new ChangeTrackingList(); + DataSources = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of file identifiers. + /// List of Azure assets. + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal CreateVectorStoreFileBatchRequest(IReadOnlyList fileIds, IReadOnlyList dataSources, VectorStoreChunkingStrategyRequest chunkingStrategy, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + DataSources = dataSources; + ChunkingStrategy = chunkingStrategy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// List of file identifiers. + public IReadOnlyList FileIds { get; } + /// List of Azure assets. + public IReadOnlyList DataSources { get; } + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public VectorStoreChunkingStrategyRequest ChunkingStrategy { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileRequest.Serialization.cs new file mode 100644 index 000000000000..9f4a2587c5f2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileRequest.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class CreateVectorStoreFileRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateVectorStoreFileRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (Optional.IsDefined(DataSource)) + { + writer.WritePropertyName("data_source"u8); + writer.WriteObjectValue(DataSource, options); + } + if (Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateVectorStoreFileRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateVectorStoreFileRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateVectorStoreFileRequest(document.RootElement, options); + } + + internal static CreateVectorStoreFileRequest DeserializeCreateVectorStoreFileRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + VectorStoreDataSource dataSource = default; + VectorStoreChunkingStrategyRequest chunkingStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("data_source"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataSource = VectorStoreDataSource.DeserializeVectorStoreDataSource(property.Value, options); + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + chunkingStrategy = VectorStoreChunkingStrategyRequest.DeserializeVectorStoreChunkingStrategyRequest(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateVectorStoreFileRequest(fileId, dataSource, chunkingStrategy, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateVectorStoreFileRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateVectorStoreFileRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateVectorStoreFileRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateVectorStoreFileRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateVectorStoreFileRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateVectorStoreFileRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileRequest.cs new file mode 100644 index 000000000000..07cc19c8816f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreFileRequest.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The CreateVectorStoreFileRequest. + internal partial class CreateVectorStoreFileRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal CreateVectorStoreFileRequest() + { + } + + /// Initializes a new instance of . + /// Identifier of the file. + /// Azure asset ID. + /// + /// The chunking strategy used to chunk the file. If not set, uses the auto strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal CreateVectorStoreFileRequest(string fileId, VectorStoreDataSource dataSource, VectorStoreChunkingStrategyRequest chunkingStrategy, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + DataSource = dataSource; + ChunkingStrategy = chunkingStrategy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Identifier of the file. + public string FileId { get; } + /// Azure asset ID. + public VectorStoreDataSource DataSource { get; } + /// + /// The chunking strategy used to chunk the file. If not set, uses the auto strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public VectorStoreChunkingStrategyRequest ChunkingStrategy { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreRequest.Serialization.cs new file mode 100644 index 000000000000..564ec6616843 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreRequest.Serialization.cs @@ -0,0 +1,255 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class CreateVectorStoreRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateVectorStoreRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(StoreConfiguration)) + { + writer.WritePropertyName("configuration"u8); + writer.WriteObjectValue(StoreConfiguration, options); + } + if (Optional.IsDefined(ExpiresAfter)) + { + writer.WritePropertyName("expires_after"u8); + writer.WriteObjectValue(ExpiresAfter, options); + } + if (Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateVectorStoreRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateVectorStoreRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateVectorStoreRequest(document.RootElement, options); + } + + internal static CreateVectorStoreRequest DeserializeCreateVectorStoreRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList fileIds = default; + string name = default; + VectorStoreConfiguration configuration = default; + VectorStoreExpirationPolicy expiresAfter = default; + VectorStoreChunkingStrategyRequest chunkingStrategy = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("configuration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + configuration = VectorStoreConfiguration.DeserializeVectorStoreConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("expires_after"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + chunkingStrategy = VectorStoreChunkingStrategyRequest.DeserializeVectorStoreChunkingStrategyRequest(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateVectorStoreRequest( + fileIds ?? new ChangeTrackingList(), + name, + configuration, + expiresAfter, + chunkingStrategy, + metadata ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateVectorStoreRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateVectorStoreRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateVectorStoreRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateVectorStoreRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateVectorStoreRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateVectorStoreRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreRequest.cs new file mode 100644 index 000000000000..9b5331a0baf7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/CreateVectorStoreRequest.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The CreateVectorStoreRequest. + internal partial class CreateVectorStoreRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal CreateVectorStoreRequest() + { + FileIds = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. + /// The name of the vector store. + /// The vector store configuration, used when vector store is created from Azure asset URIs. + /// Details on when this vector store expires. + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal CreateVectorStoreRequest(IReadOnlyList fileIds, string name, VectorStoreConfiguration storeConfiguration, VectorStoreExpirationPolicy expiresAfter, VectorStoreChunkingStrategyRequest chunkingStrategy, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + Name = name; + StoreConfiguration = storeConfiguration; + ExpiresAfter = expiresAfter; + ChunkingStrategy = chunkingStrategy; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. + public IReadOnlyList FileIds { get; } + /// The name of the vector store. + public string Name { get; } + /// The vector store configuration, used when vector store is created from Azure asset URIs. + public VectorStoreConfiguration StoreConfiguration { get; } + /// Details on when this vector store expires. + public VectorStoreExpirationPolicy ExpiresAfter { get; } + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public VectorStoreChunkingStrategyRequest ChunkingStrategy { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/DoneEvent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/DoneEvent.cs new file mode 100644 index 000000000000..68f35672561e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/DoneEvent.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Terminal event indicating the successful end of a stream. + public readonly partial struct DoneEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DoneEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DoneValue = "done"; + + /// Event sent when the stream is done. + public static DoneEvent Done { get; } = new DoneEvent(DoneValue); + /// Determines if two values are the same. + public static bool operator ==(DoneEvent left, DoneEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DoneEvent left, DoneEvent right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DoneEvent(string value) => new DoneEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DoneEvent other && Equals(other); + /// + public bool Equals(DoneEvent 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.Agents.Persistent/src/Generated/ErrorEvent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ErrorEvent.cs new file mode 100644 index 000000000000..fb191877e4ac --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ErrorEvent.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Terminal event indicating a server side error while streaming. + public readonly partial struct ErrorEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ErrorEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ErrorValue = "error"; + + /// Event sent when an error occurs, such as an internal server error or a timeout. + public static ErrorEvent Error { get; } = new ErrorEvent(ErrorValue); + /// Determines if two values are the same. + public static bool operator ==(ErrorEvent left, ErrorEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ErrorEvent left, ErrorEvent right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ErrorEvent(string value) => new ErrorEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ErrorEvent other && Equals(other); + /// + public bool Equals(ErrorEvent 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.Agents.Persistent/src/Generated/File.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/File.Serialization.cs new file mode 100644 index 000000000000..4118a4ac4977 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/File.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class File : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(File)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ContentType)) + { + writer.WritePropertyName("contentType"u8); + writer.WriteStringValue(ContentType); + } + if (Optional.IsDefined(Filename)) + { + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + writer.WritePropertyName("contents"u8); + writer.WriteBase64StringValue(Contents.ToArray(), "D"); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + File IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(File)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFile(document.RootElement, options); + } + + internal static File DeserializeFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string contentType = default; + string filename = default; + BinaryData contents = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("contentType"u8)) + { + contentType = property.Value.GetString(); + continue; + } + if (property.NameEquals("filename"u8)) + { + filename = property.Value.GetString(); + continue; + } + if (property.NameEquals("contents"u8)) + { + contents = BinaryData.FromBytes(property.Value.GetBytesFromBase64("D")); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new File(contentType, filename, contents, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(File)} does not support writing '{options.Format}' format."); + } + } + + File IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(File)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static File FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFile(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/File.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/File.cs new file mode 100644 index 000000000000..9eccea3525fd --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/File.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A file in an HTTP request, response, or multipart payload. + /// + /// Files have a special meaning that the HTTP library understands. When the body of an HTTP request, response, + /// or multipart payload is _effectively_ an instance of `TypeSpec.Http.File` or any type that extends it, the + /// operation is treated as a file upload or download. + /// + /// When using file bodies, the fields of the file model are defined to come from particular locations by default: + /// + /// - `contentType`: The `Content-Type` header of the request, response, or multipart payload (CANNOT be overridden or changed). + /// - `contents`: The body of the request, response, or multipart payload (CANNOT be overridden or changed). + /// - `filename`: The `filename` parameter value of the `Content-Disposition` header of the response or multipart payload + /// (MAY be overridden or changed). + /// + /// A File may be used as a normal structured JSON object in a request or response, if the request specifies an explicit + /// `Content-Type` header. In this case, the entire File model is serialized as if it were any other model. In a JSON payload, + /// it will have a structure like: + /// + /// ``` + /// { + /// "contentType": <string?>, + /// "filename": <string?>, + /// "contents": <string, base64> + /// } + /// ``` + /// + /// The `contentType` _within_ the file defines what media types the data inside the file can be, but if the specification + /// defines a `Content-Type` for the payload as HTTP metadata, that `Content-Type` metadata defines _how the file is + /// serialized_. See the examples below for more information. + /// + /// NOTE: The `filename` and `contentType` fields are optional. Furthermore, the default location of `filename` + /// (`Content-Disposition: <disposition>; filename=<filename>`) is only valid in HTTP responses and multipart payloads. If + /// you wish to send the `filename` in a request, you must use HTTP metadata decorators to describe the location of the + /// `filename` field. You can combine the metadata decorators with `@visibility` to control when the `filename` location + /// is overridden, as shown in the examples below. + /// + public partial class File + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// The contents of the file. + /// + /// In file bodies, this value comes from the body of the request, response, or multipart payload. In JSON bodies, + /// this value is serialized as a field in the response. + /// + /// is null. + public File(BinaryData contents) + { + Argument.AssertNotNull(contents, nameof(contents)); + + Contents = contents; + } + + /// Initializes a new instance of . + /// + /// The allowed media (MIME) types of the file contents. + /// + /// In file bodies, this value comes from the `Content-Type` header of the request or response. In JSON bodies, + /// this value is serialized as a field in the response. + /// + /// NOTE: this is not _necessarily_ the same as the `Content-Type` header of the request or response, but + /// it will be for file bodies. It may be different if the file is serialized as a JSON object. It always refers to the + /// _contents_ of the file, and not necessarily the way the file itself is transmitted or serialized. + /// + /// + /// The name of the file, if any. + /// + /// In file bodies, this value comes from the `filename` parameter of the `Content-Disposition` header of the response + /// or multipart payload. In JSON bodies, this value is serialized as a field in the response. + /// + /// NOTE: By default, `filename` cannot be sent in request payloads and can only be sent in responses and multipart + /// payloads, as the `Content-Disposition` header is not valid in requests. If you want to send the `filename` in a request, + /// you must extend the `File` model and override the `filename` property with a different location defined by HTTP metadata + /// decorators. + /// + /// + /// The contents of the file. + /// + /// In file bodies, this value comes from the body of the request, response, or multipart payload. In JSON bodies, + /// this value is serialized as a field in the response. + /// + /// Keeps track of any properties unknown to the library. + internal File(string contentType, string filename, BinaryData contents, IDictionary serializedAdditionalRawData) + { + ContentType = contentType; + Filename = filename; + Contents = contents; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal File() + { + } + + /// + /// The allowed media (MIME) types of the file contents. + /// + /// In file bodies, this value comes from the `Content-Type` header of the request or response. In JSON bodies, + /// this value is serialized as a field in the response. + /// + /// NOTE: this is not _necessarily_ the same as the `Content-Type` header of the request or response, but + /// it will be for file bodies. It may be different if the file is serialized as a JSON object. It always refers to the + /// _contents_ of the file, and not necessarily the way the file itself is transmitted or serialized. + /// + public string ContentType { get; set; } + /// + /// The name of the file, if any. + /// + /// In file bodies, this value comes from the `filename` parameter of the `Content-Disposition` header of the response + /// or multipart payload. In JSON bodies, this value is serialized as a field in the response. + /// + /// NOTE: By default, `filename` cannot be sent in request payloads and can only be sent in responses and multipart + /// payloads, as the `Content-Disposition` header is not valid in requests. If you want to send the `filename` in a request, + /// you must extend the `File` model and override the `filename` property with a different location defined by HTTP metadata + /// decorators. + /// + public string Filename { get; set; } + /// + /// The contents of the file. + /// + /// In file bodies, this value comes from the body of the request, response, or multipart payload. In JSON bodies, + /// this value is serialized as a field in the response. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData Contents { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchRankingOptions.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchRankingOptions.Serialization.cs new file mode 100644 index 000000000000..0588e1a619f6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchRankingOptions.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class FileSearchRankingOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("ranker"u8); + writer.WriteStringValue(Ranker); + writer.WritePropertyName("score_threshold"u8); + writer.WriteNumberValue(ScoreThreshold); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FileSearchRankingOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchRankingOptions(document.RootElement, options); + } + + internal static FileSearchRankingOptions DeserializeFileSearchRankingOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string ranker = default; + float scoreThreshold = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ranker"u8)) + { + ranker = property.Value.GetString(); + continue; + } + if (property.NameEquals("score_threshold"u8)) + { + scoreThreshold = property.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchRankingOptions(ranker, scoreThreshold, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support writing '{options.Format}' format."); + } + } + + FileSearchRankingOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchRankingOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FileSearchRankingOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchRankingOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchRankingOptions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchRankingOptions.cs new file mode 100644 index 000000000000..bdbe61ce8504 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchRankingOptions.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Ranking options for file search. + public partial class FileSearchRankingOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// File search ranker. + /// Ranker search threshold. + /// is null. + public FileSearchRankingOptions(string ranker, float scoreThreshold) + { + Argument.AssertNotNull(ranker, nameof(ranker)); + + Ranker = ranker; + ScoreThreshold = scoreThreshold; + } + + /// Initializes a new instance of . + /// File search ranker. + /// Ranker search threshold. + /// Keeps track of any properties unknown to the library. + internal FileSearchRankingOptions(string ranker, float scoreThreshold, IDictionary serializedAdditionalRawData) + { + Ranker = ranker; + ScoreThreshold = scoreThreshold; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FileSearchRankingOptions() + { + } + + /// File search ranker. + public string Ranker { get; set; } + /// Ranker search threshold. + public float ScoreThreshold { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContent.Serialization.cs new file mode 100644 index 000000000000..b4881d2ede75 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContent.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class FileSearchToolCallContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolCallContent)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FileSearchToolCallContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolCallContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolCallContent(document.RootElement, options); + } + + internal static FileSearchToolCallContent DeserializeFileSearchToolCallContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + FileSearchToolCallContentType type = default; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new FileSearchToolCallContentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolCallContent(type, text, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchToolCallContent)} does not support writing '{options.Format}' format."); + } + } + + FileSearchToolCallContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchToolCallContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolCallContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FileSearchToolCallContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchToolCallContent(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContent.cs new file mode 100644 index 000000000000..a17926927ea8 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContent.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The file search result content object. + public partial class FileSearchToolCallContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The text content of the file. + /// is null. + internal FileSearchToolCallContent(string text) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Initializes a new instance of . + /// The type of the content. + /// The text content of the file. + /// Keeps track of any properties unknown to the library. + internal FileSearchToolCallContent(FileSearchToolCallContentType type, string text, IDictionary serializedAdditionalRawData) + { + Type = type; + Text = text; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FileSearchToolCallContent() + { + } + + /// The type of the content. + public FileSearchToolCallContentType Type { get; } = FileSearchToolCallContentType.Text; + + /// The text content of the file. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContentType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContentType.cs new file mode 100644 index 000000000000..c0d81d77d9c4 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolCallContentType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The FileSearchToolCallContent_type. + public readonly partial struct FileSearchToolCallContentType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FileSearchToolCallContentType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TextValue = "text"; + + /// text. + public static FileSearchToolCallContentType Text { get; } = new FileSearchToolCallContentType(TextValue); + /// Determines if two values are the same. + public static bool operator ==(FileSearchToolCallContentType left, FileSearchToolCallContentType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FileSearchToolCallContentType left, FileSearchToolCallContentType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator FileSearchToolCallContentType(string value) => new FileSearchToolCallContentType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileSearchToolCallContentType other && Equals(other); + /// + public bool Equals(FileSearchToolCallContentType 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.Agents.Persistent/src/Generated/FileSearchToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinition.Serialization.cs new file mode 100644 index 000000000000..072c8aef5159 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinition.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class FileSearchToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + } + + FileSearchToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolDefinition(document.RootElement, options); + } + + internal static FileSearchToolDefinition DeserializeFileSearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + FileSearchToolDefinitionDetails fileSearch = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileSearch = FileSearchToolDefinitionDetails.DeserializeFileSearchToolDefinitionDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolDefinition(type, serializedAdditionalRawData, fileSearch); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + FileSearchToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new FileSearchToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinition.cs new file mode 100644 index 000000000000..4ca68ca24e62 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinition.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for a file search tool as used to configure an agent. + public partial class FileSearchToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + public FileSearchToolDefinition() + { + Type = "file_search"; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// Options overrides for the file search tool. + internal FileSearchToolDefinition(string type, IDictionary serializedAdditionalRawData, FileSearchToolDefinitionDetails fileSearch) : base(type, serializedAdditionalRawData) + { + FileSearch = fileSearch; + } + + /// Options overrides for the file search tool. + public FileSearchToolDefinitionDetails FileSearch { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs new file mode 100644 index 000000000000..43aaa019a789 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class FileSearchToolDefinitionDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolDefinitionDetails)} does not support writing '{format}' format."); + } + + 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 (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FileSearchToolDefinitionDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolDefinitionDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolDefinitionDetails(document.RootElement, options); + } + + internal static FileSearchToolDefinitionDetails DeserializeFileSearchToolDefinitionDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? maxNumResults = default; + FileSearchRankingOptions rankingOptions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("max_num_results"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxNumResults = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("ranking_options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rankingOptions = FileSearchRankingOptions.DeserializeFileSearchRankingOptions(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolDefinitionDetails(maxNumResults, rankingOptions, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinitionDetails)} does not support writing '{options.Format}' format."); + } + } + + FileSearchToolDefinitionDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchToolDefinitionDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinitionDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FileSearchToolDefinitionDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchToolDefinitionDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinitionDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinitionDetails.cs new file mode 100644 index 000000000000..3e7a8d3e7c3d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolDefinitionDetails.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Options overrides for the file search tool. + public partial class FileSearchToolDefinitionDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public FileSearchToolDefinitionDetails() + { + } + + /// Initializes a new instance of . + /// + /// The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. + /// + /// Note that the file search tool may output fewer than `max_num_results` results. See the file search tool documentation for more information. + /// + /// Ranking options for file search. + /// Keeps track of any properties unknown to the library. + internal FileSearchToolDefinitionDetails(int? maxNumResults, FileSearchRankingOptions rankingOptions, IDictionary serializedAdditionalRawData) + { + MaxNumResults = maxNumResults; + RankingOptions = rankingOptions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. + /// + /// Note that the file search tool may output fewer than `max_num_results` results. See the file search tool documentation for more information. + /// + public int? MaxNumResults { get; set; } + /// Ranking options for file search. + public FileSearchRankingOptions RankingOptions { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolResource.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolResource.Serialization.cs new file mode 100644 index 000000000000..0ab42ef41818 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolResource.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class FileSearchToolResource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(VectorStoreIds)) + { + writer.WritePropertyName("vector_store_ids"u8); + writer.WriteStartArray(); + foreach (var item in VectorStoreIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(VectorStores)) + { + writer.WritePropertyName("vector_stores"u8); + writer.WriteStartArray(); + foreach (var item in VectorStores) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FileSearchToolResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolResource(document.RootElement, options); + } + + internal static FileSearchToolResource DeserializeFileSearchToolResource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList vectorStoreIds = default; + IList vectorStores = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vector_store_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + vectorStoreIds = array; + continue; + } + if (property.NameEquals("vector_stores"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VectorStoreConfigurations.DeserializeVectorStoreConfigurations(item, options)); + } + vectorStores = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolResource(vectorStoreIds ?? new ChangeTrackingList(), vectorStores ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support writing '{options.Format}' format."); + } + } + + FileSearchToolResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchToolResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FileSearchToolResource FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileSearchToolResource(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolResource.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolResource.cs new file mode 100644 index 000000000000..765e4400325d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileSearchToolResource.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A set of resources that are used by the `file_search` tool. + public partial class FileSearchToolResource + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public FileSearchToolResource() + { + VectorStoreIds = new ChangeTrackingList(); + VectorStores = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// The ID of the vector store attached to this agent. There can be a maximum of 1 vector + /// store attached to the agent. + /// + /// + /// The list of vector store configuration objects from Azure. + /// This list is limited to one element. + /// The only element of this list contains the list of azure asset IDs used by the search tool. + /// + /// Keeps track of any properties unknown to the library. + internal FileSearchToolResource(IList vectorStoreIds, IList vectorStores, IDictionary serializedAdditionalRawData) + { + VectorStoreIds = vectorStoreIds; + VectorStores = vectorStores; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The ID of the vector store attached to this agent. There can be a maximum of 1 vector + /// store attached to the agent. + /// + public IList VectorStoreIds { get; } + /// + /// The list of vector store configuration objects from Azure. + /// This list is limited to one element. + /// The only element of this list contains the list of azure asset IDs used by the search tool. + /// + public IList VectorStores { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileState.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileState.cs new file mode 100644 index 000000000000..cf909a8597d4 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FileState.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The state of the file. + public readonly partial struct FileState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FileState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UploadedValue = "uploaded"; + private const string PendingValue = "pending"; + private const string RunningValue = "running"; + private const string ProcessedValue = "processed"; + private const string ErrorValue = "error"; + private const string DeletingValue = "deleting"; + private const string DeletedValue = "deleted"; + + /// + /// The file has been uploaded but it's not yet processed. This state is not returned by Azure OpenAI and exposed only for + /// compatibility. It can be categorized as an inactive state. + /// + public static FileState Uploaded { get; } = new FileState(UploadedValue); + /// The operation was created and is not queued to be processed in the future. It can be categorized as an inactive state. + public static FileState Pending { get; } = new FileState(PendingValue); + /// The operation has started to be processed. It can be categorized as an active state. + public static FileState Running { get; } = new FileState(RunningValue); + /// The operation has successfully processed and is ready for consumption. It can be categorized as a terminal state. + public static FileState Processed { get; } = new FileState(ProcessedValue); + /// The operation has completed processing with a failure and cannot be further consumed. It can be categorized as a terminal state. + public static FileState Error { get; } = new FileState(ErrorValue); + /// + /// The entity is in the process to be deleted. This state is not returned by Azure OpenAI and exposed only for compatibility. + /// It can be categorized as an active state. + /// + public static FileState Deleting { get; } = new FileState(DeletingValue); + /// + /// The entity has been deleted but may still be referenced by other entities predating the deletion. It can be categorized as a + /// terminal state. + /// + public static FileState Deleted { get; } = new FileState(DeletedValue); + /// Determines if two values are the same. + public static bool operator ==(FileState left, FileState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FileState left, FileState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator FileState(string value) => new FileState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileState other && Equals(other); + /// + public bool Equals(FileState 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.Agents.Persistent/src/Generated/Files.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Files.cs new file mode 100644 index 000000000000..6dce8802a3bd --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Files.cs @@ -0,0 +1,665 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Agents.Persistent +{ + // Data plane generated sub-client. + /// A collection of file‐related operations under `/files`. + public partial class Files + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Files for mocking. + protected Files() + { + } + + /// Initializes a new instance of Files. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Files(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Gets a list of previously uploaded files. + /// The purpose of the file. + /// The cancellation token to use. + internal virtual async Task> InternalListFilesAsync(OpenAIFilePurpose? purpose = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalListFilesAsync(purpose?.ToString(), context).ConfigureAwait(false); + return Response.FromValue(InternalFileListResponse.FromResponse(response), response); + } + + /// Gets a list of previously uploaded files. + /// The purpose of the file. + /// The cancellation token to use. + internal virtual Response InternalListFiles(OpenAIFilePurpose? purpose = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalListFiles(purpose?.ToString(), context); + return Response.FromValue(InternalFileListResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of previously uploaded files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The purpose of the file. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output" | "batch" | "batch_output" | "vision". + /// The request context, 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. + internal virtual async Task InternalListFilesAsync(string purpose, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("Files.InternalListFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalListFilesRequest(purpose, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a list of previously uploaded files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The purpose of the file. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output" | "batch" | "batch_output" | "vision". + /// The request context, 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. + internal virtual Response InternalListFiles(string purpose, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("Files.InternalListFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalListFilesRequest(purpose, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Uploads a file for use by other operations. + /// Multipart body. + /// The cancellation token to use. + /// is null. + public virtual async Task> UploadFileAsync(UploadFileRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using MultipartFormDataRequestContent content = body.ToMultipartRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UploadFileAsync(content, content.ContentType, context).ConfigureAwait(false); + return Response.FromValue(OpenAIFile.FromResponse(response), response); + } + + /// Uploads a file for use by other operations. + /// Multipart body. + /// The cancellation token to use. + /// is null. + public virtual Response UploadFile(UploadFileRequest body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using MultipartFormDataRequestContent content = body.ToMultipartRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UploadFile(content, content.ContentType, context); + return Response.FromValue(OpenAIFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Uploads a file for use by other operations. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The name of the file to upload. Allowed values: "multipart/form-data". + /// The request context, 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 UploadFileAsync(RequestContent content, string contentType, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Files.UploadFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadFileRequest(content, contentType, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Uploads a file for use by other operations. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The name of the file to upload. Allowed values: "multipart/form-data". + /// The request context, 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 Response UploadFile(RequestContent content, string contentType, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Files.UploadFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadFileRequest(content, contentType, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete a previously uploaded file. + /// The ID of the file to delete. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalDeleteFileAsync(string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalDeleteFileAsync(fileId, context).ConfigureAwait(false); + return Response.FromValue(InternalFileDeletionStatus.FromResponse(response), response); + } + + /// Delete a previously uploaded file. + /// The ID of the file to delete. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response InternalDeleteFile(string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalDeleteFile(fileId, context); + return Response.FromValue(InternalFileDeletionStatus.FromResponse(response), response); + } + + /// + /// [Protocol Method] Delete a previously uploaded file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the file to delete. + /// The request context, 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. + internal virtual async Task InternalDeleteFileAsync(string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("Files.InternalDeleteFile"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalDeleteFileRequest(fileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Delete a previously uploaded file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the file to delete. + /// The request context, 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. + internal virtual Response InternalDeleteFile(string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("Files.InternalDeleteFile"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalDeleteFileRequest(fileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Returns information about a specific file. Does not retrieve file content. + /// The ID of the file to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetFileAsync(string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetFileAsync(fileId, context).ConfigureAwait(false); + return Response.FromValue(OpenAIFile.FromResponse(response), response); + } + + /// Returns information about a specific file. Does not retrieve file content. + /// The ID of the file to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetFile(string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetFile(fileId, context); + return Response.FromValue(OpenAIFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the file to retrieve. + /// The request context, 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 GetFileAsync(string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("Files.GetFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetFileRequest(fileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the file to retrieve. + /// The request context, 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 Response GetFile(string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("Files.GetFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetFileRequest(fileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves the raw content of a specific file. + /// The ID of the file to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetFileContentAsync(string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetFileContentAsync(fileId, context).ConfigureAwait(false); + return Response.FromValue(response.Content, response); + } + + /// Retrieves the raw content of a specific file. + /// The ID of the file to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetFileContent(string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetFileContent(fileId, context); + return Response.FromValue(response.Content, response); + } + + /// + /// [Protocol Method] Retrieves the raw content of a specific file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the file to retrieve. + /// The request context, 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 GetFileContentAsync(string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("Files.GetFileContent"); + scope.Start(); + try + { + using HttpMessage message = CreateGetFileContentRequest(fileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves the raw content of a specific file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the file to retrieve. + /// The request context, 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 Response GetFileContent(string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("Files.GetFileContent"); + scope.Start(); + try + { + using HttpMessage message = CreateGetFileContentRequest(fileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateInternalListFilesRequest(string purpose, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (purpose != null) + { + uri.AppendQuery("purpose", purpose, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUploadFileRequest(RequestContent content, string contentType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", contentType); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalDeleteFileRequest(string fileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetFileRequest(string fileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetFileContentRequest(string fileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + uri.AppendPath("/content", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/octet-stream"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionName.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionName.Serialization.cs new file mode 100644 index 000000000000..bd3915204fb1 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionName.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class FunctionName : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionName)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FunctionName IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionName)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionName(document.RootElement, options); + } + + internal static FunctionName DeserializeFunctionName(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FunctionName(name, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FunctionName)} does not support writing '{options.Format}' format."); + } + } + + FunctionName IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFunctionName(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionName)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FunctionName FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFunctionName(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionName.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionName.cs new file mode 100644 index 000000000000..32c48b9df3ab --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionName.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The function name that will be used, if using the `function` tool. + public partial class FunctionName + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The name of the function to call. + /// is null. + public FunctionName(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + /// Initializes a new instance of . + /// The name of the function to call. + /// Keeps track of any properties unknown to the library. + internal FunctionName(string name, IDictionary serializedAdditionalRawData) + { + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FunctionName() + { + } + + /// The name of the function to call. + public string Name { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionToolDefinition.Serialization.cs new file mode 100644 index 000000000000..b8cfa1adf582 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionToolDefinition.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class FunctionToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(InternalFunction, options); + } + + FunctionToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionToolDefinition(document.RootElement, options); + } + + internal static FunctionToolDefinition DeserializeFunctionToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalFunctionDefinition function = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("function"u8)) + { + function = InternalFunctionDefinition.DeserializeInternalFunctionDefinition(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FunctionToolDefinition(type, serializedAdditionalRawData, function); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + FunctionToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFunctionToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new FunctionToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFunctionToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionToolDefinition.cs new file mode 100644 index 000000000000..0a45fa61b2be --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/FunctionToolDefinition.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for a function tool as used to configure an agent. + public partial class FunctionToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + /// The definition of the concrete function that the function tool should call. + /// is null. + public FunctionToolDefinition(InternalFunctionDefinition internalFunction) + { + Argument.AssertNotNull(internalFunction, nameof(internalFunction)); + + Type = "function"; + InternalFunction = internalFunction; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The definition of the concrete function that the function tool should call. + internal FunctionToolDefinition(string type, IDictionary serializedAdditionalRawData, InternalFunctionDefinition internalFunction) : base(type, serializedAdditionalRawData) + { + InternalFunction = internalFunction; + } + + /// Initializes a new instance of for deserialization. + internal FunctionToolDefinition() + { + } + + /// The definition of the concrete function that the function tool should call. + public InternalFunctionDefinition InternalFunction { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ImageDetailLevel.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ImageDetailLevel.cs new file mode 100644 index 000000000000..5e913a717116 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ImageDetailLevel.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Specifies an image's detail level. Can be 'auto', 'low', 'high', or an unknown future value. + public readonly partial struct ImageDetailLevel : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ImageDetailLevel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutoValue = "auto"; + private const string LowValue = "low"; + private const string HighValue = "high"; + + /// Automatically select an appropriate detail level. + public static ImageDetailLevel Auto { get; } = new ImageDetailLevel(AutoValue); + /// Use a lower detail level to reduce bandwidth or cost. + public static ImageDetailLevel Low { get; } = new ImageDetailLevel(LowValue); + /// Use a higher detail level—potentially more resource-intensive. + public static ImageDetailLevel High { get; } = new ImageDetailLevel(HighValue); + /// Determines if two values are the same. + public static bool operator ==(ImageDetailLevel left, ImageDetailLevel right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ImageDetailLevel left, ImageDetailLevel right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ImageDetailLevel(string value) => new ImageDetailLevel(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageDetailLevel other && Equals(other); + /// + public bool Equals(ImageDetailLevel 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.Agents.Persistent/src/Generated/IncompleteDetailsReason.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/IncompleteDetailsReason.cs new file mode 100644 index 000000000000..a4109a3d1206 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/IncompleteDetailsReason.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. + public readonly partial struct IncompleteDetailsReason : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public IncompleteDetailsReason(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string MaxCompletionTokensValue = "max_completion_tokens"; + private const string MaxPromptTokensValue = "max_prompt_tokens"; + + /// Maximum completion tokens exceeded. + public static IncompleteDetailsReason MaxCompletionTokens { get; } = new IncompleteDetailsReason(MaxCompletionTokensValue); + /// Maximum prompt tokens exceeded. + public static IncompleteDetailsReason MaxPromptTokens { get; } = new IncompleteDetailsReason(MaxPromptTokensValue); + /// Determines if two values are the same. + public static bool operator ==(IncompleteDetailsReason left, IncompleteDetailsReason right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(IncompleteDetailsReason left, IncompleteDetailsReason right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator IncompleteDetailsReason(string value) => new IncompleteDetailsReason(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is IncompleteDetailsReason other && Equals(other); + /// + public bool Equals(IncompleteDetailsReason 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.Agents.Persistent/src/Generated/IncompleteRunDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/IncompleteRunDetails.Serialization.cs new file mode 100644 index 000000000000..dfb3518e7bca --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/IncompleteRunDetails.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class IncompleteRunDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IncompleteRunDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + IncompleteRunDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IncompleteRunDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIncompleteRunDetails(document.RootElement, options); + } + + internal static IncompleteRunDetails DeserializeIncompleteRunDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IncompleteDetailsReason reason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("reason"u8)) + { + reason = new IncompleteDetailsReason(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IncompleteRunDetails(reason, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(IncompleteRunDetails)} does not support writing '{options.Format}' format."); + } + } + + IncompleteRunDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIncompleteRunDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IncompleteRunDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static IncompleteRunDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIncompleteRunDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/IncompleteRunDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/IncompleteRunDetails.cs new file mode 100644 index 000000000000..7e0d64c85478 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/IncompleteRunDetails.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. + public partial class IncompleteRunDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The reason why the run is incomplete. This indicates which specific token limit was reached during the run. + internal IncompleteRunDetails(IncompleteDetailsReason reason) + { + Reason = reason; + } + + /// Initializes a new instance of . + /// The reason why the run is incomplete. This indicates which specific token limit was reached during the run. + /// Keeps track of any properties unknown to the library. + internal IncompleteRunDetails(IncompleteDetailsReason reason, IDictionary serializedAdditionalRawData) + { + Reason = reason; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IncompleteRunDetails() + { + } + + /// The reason why the run is incomplete. This indicates which specific token limit was reached during the run. + public IncompleteDetailsReason Reason { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Argument.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..f1ba25bcb02e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(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); + } + } + + 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); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..e8129d7f8dfd --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + 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.Agents.Persistent/src/Generated/Internal/ChangeTrackingList.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..e62870e3eb4f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// 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.Linq; + +namespace Azure.AI.Agents.Persistent +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + 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(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + 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.Agents.Persistent/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..1800679caec5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,399 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + 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: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var 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) + { + var 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) + { + var 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 IUtf8JsonSerializable serializable: + serializable.Write(writer); + 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); + } + + internal static 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}. Azure SDK requires 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" => 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" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => 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 format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/MultipartFormDataRequestContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/MultipartFormDataRequestContent.cs new file mode 100644 index 000000000000..95299f77254f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/MultipartFormDataRequestContent.cs @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.IO; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Agents.Persistent +{ + internal class MultipartFormDataRequestContent : RequestContent + { + private readonly System.Net.Http.MultipartFormDataContent _multipartContent; + private static readonly Random _random = new Random(); + private static readonly char[] _boundaryValues = "0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".ToCharArray(); + + public MultipartFormDataRequestContent() + { + _multipartContent = new System.Net.Http.MultipartFormDataContent(CreateBoundary()); + } + + public string ContentType + { + get + { + return _multipartContent.Headers.ContentType.ToString(); + } + } + + internal HttpContent HttpContent => _multipartContent; + + private static string CreateBoundary() + { + Span chars = new char[70]; + byte[] random = new byte[70]; + _random.NextBytes(random); + int mask = 255 >> 2; + for (int i = 0; i < 70; i++) + { + chars[i] = _boundaryValues[random[i] & mask]; + } + return chars.ToString(); + } + + public void Add(string content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new StringContent(content), name, filename, contentType); + } + + public void Add(int content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(long content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(float content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(double content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(decimal content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content.ToString("G", CultureInfo.InvariantCulture); + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(bool content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + string value = content ? "true" : "false"; + Add(new StringContent(value), name, filename, contentType); + } + + public void Add(Stream content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new StreamContent(content), name, filename, contentType); + } + + public void Add(byte[] content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new ByteArrayContent(content), name, filename, contentType); + } + + public void Add(BinaryData content, string name, string filename = null, string contentType = null) + { + Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + Add(new ByteArrayContent(content.ToArray()), name, filename, contentType); + } + + private void Add(HttpContent content, string name, string filename, string contentType) + { + if (filename != null) + { + Argument.AssertNotNullOrEmpty(filename, nameof(filename)); + AddFilenameHeader(content, name, filename); + } + if (contentType != null) + { + Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); + AddContentTypeHeader(content, contentType); + } + _multipartContent.Add(content, name); + } + + public static void AddFilenameHeader(HttpContent content, string name, string filename) + { + ContentDispositionHeaderValue header = new ContentDispositionHeaderValue("form-data") { Name = name, FileName = filename }; + content.Headers.ContentDisposition = header; + } + + public static void AddContentTypeHeader(HttpContent content, string contentType) + { + MediaTypeHeaderValue header = new MediaTypeHeaderValue(contentType); + content.Headers.ContentType = header; + } + + public override bool TryComputeLength(out long length) + { + if (_multipartContent.Headers.ContentLength is long contentLength) + { + length = contentLength; + return true; + } + length = 0; + return false; + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { +#if NET6_0_OR_GREATER + _multipartContent.CopyTo(stream, default, cancellationToken); +#else +#pragma warning disable AZC0107 + _multipartContent.CopyToAsync(stream).EnsureCompleted(); +#pragma warning restore AZC0107 +#endif + } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { +#if NET6_0_OR_GREATER + await _multipartContent.CopyToAsync(stream, cancellationToken).ConfigureAwait(false); +#else + await _multipartContent.CopyToAsync(stream).ConfigureAwait(false); +#endif + } + + public override void Dispose() + { + _multipartContent.Dispose(); + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Optional.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..0310535e6fd7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Agents.Persistent +{ + internal static 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(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..e696fd4e73cb --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatus.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatus.Serialization.cs new file mode 100644 index 000000000000..8059c058fc58 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatus.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalAgentDeletionStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentDeletionStatus)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalAgentDeletionStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentDeletionStatus)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAgentDeletionStatus(document.RootElement, options); + } + + internal static InternalAgentDeletionStatus DeserializeInternalAgentDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalAgentDeletionStatusObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("deleted"u8)) + { + deleted = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalAgentDeletionStatusObject(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAgentDeletionStatus(id, deleted, @object, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAgentDeletionStatus)} does not support writing '{options.Format}' format."); + } + } + + InternalAgentDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalAgentDeletionStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAgentDeletionStatus)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalAgentDeletionStatus FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalAgentDeletionStatus(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatus.cs new file mode 100644 index 000000000000..dac0cabe7a0a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatus.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The status of an agent deletion operation. + internal partial class InternalAgentDeletionStatus + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// is null. + internal InternalAgentDeletionStatus(string id, bool deleted) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + Deleted = deleted; + } + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// The object type, which is always 'assistant.deleted'. + /// Keeps track of any properties unknown to the library. + internal InternalAgentDeletionStatus(string id, bool deleted, InternalAgentDeletionStatusObject @object, IDictionary serializedAdditionalRawData) + { + Id = id; + Deleted = deleted; + Object = @object; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalAgentDeletionStatus() + { + } + + /// The ID of the resource specified for deletion. + public string Id { get; } + /// A value indicating whether deletion was successful. + public bool Deleted { get; } + /// The object type, which is always 'assistant.deleted'. + public InternalAgentDeletionStatusObject Object { get; } = InternalAgentDeletionStatusObject.AssistantDeleted; + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatusObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatusObject.cs new file mode 100644 index 000000000000..cb57f938c5b4 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAgentDeletionStatusObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The InternalAgentDeletionStatus_object. + internal readonly partial struct InternalAgentDeletionStatusObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public InternalAgentDeletionStatusObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AssistantDeletedValue = "assistant.deleted"; + + /// assistant.deleted. + public static InternalAgentDeletionStatusObject AssistantDeleted { get; } = new InternalAgentDeletionStatusObject(AssistantDeletedValue); + /// Determines if two values are the same. + public static bool operator ==(InternalAgentDeletionStatusObject left, InternalAgentDeletionStatusObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(InternalAgentDeletionStatusObject left, InternalAgentDeletionStatusObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator InternalAgentDeletionStatusObject(string value) => new InternalAgentDeletionStatusObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalAgentDeletionStatusObject other && Equals(other); + /// + public bool Equals(InternalAgentDeletionStatusObject 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.Agents.Persistent/src/Generated/InternalAzureFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAzureFunctionDefinition.Serialization.cs new file mode 100644 index 000000000000..c88e75b9824f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAzureFunctionDefinition.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalAzureFunctionDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAzureFunctionDefinition)} 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalAzureFunctionDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAzureFunctionDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAzureFunctionDefinition(document.RootElement, options); + } + + internal static InternalAzureFunctionDefinition DeserializeInternalAzureFunctionDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalFunctionDefinition function = default; + AzureFunctionBinding inputBinding = default; + AzureFunctionBinding outputBinding = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("function"u8)) + { + function = InternalFunctionDefinition.DeserializeInternalFunctionDefinition(property.Value, options); + continue; + } + if (property.NameEquals("input_binding"u8)) + { + inputBinding = AzureFunctionBinding.DeserializeAzureFunctionBinding(property.Value, options); + continue; + } + if (property.NameEquals("output_binding"u8)) + { + outputBinding = AzureFunctionBinding.DeserializeAzureFunctionBinding(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAzureFunctionDefinition(function, inputBinding, outputBinding, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAzureFunctionDefinition)} does not support writing '{options.Format}' format."); + } + } + + InternalAzureFunctionDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalAzureFunctionDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAzureFunctionDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalAzureFunctionDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalAzureFunctionDefinition(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAzureFunctionDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAzureFunctionDefinition.cs new file mode 100644 index 000000000000..47dfae031c6b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalAzureFunctionDefinition.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The definition of Azure function. + internal partial class InternalAzureFunctionDefinition + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// 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 InternalAzureFunctionDefinition(InternalFunctionDefinition 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 InternalAzureFunctionDefinition(InternalFunctionDefinition function, AzureFunctionBinding inputBinding, AzureFunctionBinding outputBinding, IDictionary serializedAdditionalRawData) + { + Function = function; + InputBinding = inputBinding; + OutputBinding = outputBinding; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalAzureFunctionDefinition() + { + } + + /// The definition of azure function and its parameters. + public InternalFunctionDefinition 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.Agents.Persistent/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs new file mode 100644 index 000000000000..3cb06e471b95 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalCodeInterpreterToolCallDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("input"u8); + writer.WriteStringValue(Input); + writer.WritePropertyName("outputs"u8); + writer.WriteStartArray(); + foreach (var item in Outputs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalCodeInterpreterToolCallDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterToolCallDetails(document.RootElement, options); + } + + internal static InternalCodeInterpreterToolCallDetails DeserializeInternalCodeInterpreterToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string input = default; + IReadOnlyList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("input"u8)) + { + input = property.Value.GetString(); + continue; + } + if (property.NameEquals("outputs"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RunStepCodeInterpreterToolCallOutput.DeserializeRunStepCodeInterpreterToolCallOutput(item, options)); + } + outputs = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCodeInterpreterToolCallDetails(input, outputs, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallDetails)} does not support writing '{options.Format}' format."); + } + } + + InternalCodeInterpreterToolCallDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalCodeInterpreterToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalCodeInterpreterToolCallDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalCodeInterpreterToolCallDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalCodeInterpreterToolCallDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalCodeInterpreterToolCallDetails.cs new file mode 100644 index 000000000000..37a5c23934a9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalCodeInterpreterToolCallDetails.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The detailed information about a code interpreter invocation by the model. + internal partial class InternalCodeInterpreterToolCallDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The input provided by the model to the code interpreter tool. + /// + /// The outputs produced by the code interpreter tool back to the model in response to the tool call. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// or is null. + internal InternalCodeInterpreterToolCallDetails(string input, IEnumerable outputs) + { + Argument.AssertNotNull(input, nameof(input)); + Argument.AssertNotNull(outputs, nameof(outputs)); + + Input = input; + Outputs = outputs.ToList(); + } + + /// Initializes a new instance of . + /// The input provided by the model to the code interpreter tool. + /// + /// The outputs produced by the code interpreter tool back to the model in response to the tool call. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal InternalCodeInterpreterToolCallDetails(string input, IReadOnlyList outputs, IDictionary serializedAdditionalRawData) + { + Input = input; + Outputs = outputs; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterToolCallDetails() + { + } + + /// The input provided by the model to the code interpreter tool. + public string Input { get; } + /// + /// The outputs produced by the code interpreter tool back to the model in response to the tool call. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public IReadOnlyList Outputs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatus.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatus.Serialization.cs new file mode 100644 index 000000000000..bd3e1d54b3a9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatus.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalFileDeletionStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileDeletionStatus)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalFileDeletionStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileDeletionStatus)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileDeletionStatus(document.RootElement, options); + } + + internal static InternalFileDeletionStatus DeserializeInternalFileDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalFileDeletionStatusObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("deleted"u8)) + { + deleted = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalFileDeletionStatusObject(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFileDeletionStatus(id, deleted, @object, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFileDeletionStatus)} does not support writing '{options.Format}' format."); + } + } + + InternalFileDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalFileDeletionStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileDeletionStatus)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalFileDeletionStatus FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalFileDeletionStatus(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatus.cs new file mode 100644 index 000000000000..e879b20d7ad8 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatus.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A status response from a file deletion operation. + internal partial class InternalFileDeletionStatus + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// is null. + internal InternalFileDeletionStatus(string id, bool deleted) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + Deleted = deleted; + } + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// The object type, which is always 'file'. + /// Keeps track of any properties unknown to the library. + internal InternalFileDeletionStatus(string id, bool deleted, InternalFileDeletionStatusObject @object, IDictionary serializedAdditionalRawData) + { + Id = id; + Deleted = deleted; + Object = @object; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalFileDeletionStatus() + { + } + + /// The ID of the resource specified for deletion. + public string Id { get; } + /// A value indicating whether deletion was successful. + public bool Deleted { get; } + /// The object type, which is always 'file'. + public InternalFileDeletionStatusObject Object { get; } = InternalFileDeletionStatusObject.File; + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatusObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatusObject.cs new file mode 100644 index 000000000000..3c33bde644c5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileDeletionStatusObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The InternalFileDeletionStatus_object. + internal readonly partial struct InternalFileDeletionStatusObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public InternalFileDeletionStatusObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FileValue = "file"; + + /// file. + public static InternalFileDeletionStatusObject File { get; } = new InternalFileDeletionStatusObject(FileValue); + /// Determines if two values are the same. + public static bool operator ==(InternalFileDeletionStatusObject left, InternalFileDeletionStatusObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(InternalFileDeletionStatusObject left, InternalFileDeletionStatusObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator InternalFileDeletionStatusObject(string value) => new InternalFileDeletionStatusObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalFileDeletionStatusObject other && Equals(other); + /// + public bool Equals(InternalFileDeletionStatusObject 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.Agents.Persistent/src/Generated/InternalFileListResponse.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponse.Serialization.cs new file mode 100644 index 000000000000..3c68042d2b20 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponse.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalFileListResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileListResponse)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalFileListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileListResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileListResponse(document.RootElement, options); + } + + internal static InternalFileListResponse DeserializeInternalFileListResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalFileListResponseObject @object = default; + IReadOnlyList data = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new InternalFileListResponseObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(OpenAIFile.DeserializeOpenAIFile(item, options)); + } + data = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFileListResponse(@object, data, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFileListResponse)} does not support writing '{options.Format}' format."); + } + } + + InternalFileListResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalFileListResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileListResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalFileListResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalFileListResponse(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponse.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponse.cs new file mode 100644 index 000000000000..ba433a94cf9d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponse.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The response data from a file list operation. + internal partial class InternalFileListResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The files returned for the request. + /// is null. + internal InternalFileListResponse(IEnumerable data) + { + Argument.AssertNotNull(data, nameof(data)); + + Data = data.ToList(); + } + + /// Initializes a new instance of . + /// The object type, which is always 'list'. + /// The files returned for the request. + /// Keeps track of any properties unknown to the library. + internal InternalFileListResponse(InternalFileListResponseObject @object, IReadOnlyList data, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalFileListResponse() + { + } + + /// The object type, which is always 'list'. + public InternalFileListResponseObject Object { get; } = InternalFileListResponseObject.List; + + /// The files returned for the request. + public IReadOnlyList Data { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponseObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponseObject.cs new file mode 100644 index 000000000000..e1273f795938 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFileListResponseObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The InternalFileListResponse_object. + internal readonly partial struct InternalFileListResponseObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public InternalFileListResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static InternalFileListResponseObject List { get; } = new InternalFileListResponseObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(InternalFileListResponseObject left, InternalFileListResponseObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(InternalFileListResponseObject left, InternalFileListResponseObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator InternalFileListResponseObject(string value) => new InternalFileListResponseObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalFileListResponseObject other && Equals(other); + /// + public bool Equals(InternalFileListResponseObject 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.Agents.Persistent/src/Generated/InternalFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFunctionDefinition.Serialization.cs new file mode 100644 index 000000000000..5aa2c0925186 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFunctionDefinition.Serialization.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalFunctionDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionDefinition)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalFunctionDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionDefinition(document.RootElement, options); + } + + internal static InternalFunctionDefinition DeserializeInternalFunctionDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData parameters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("parameters"u8)) + { + parameters = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFunctionDefinition(name, description, parameters, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support writing '{options.Format}' format."); + } + } + + InternalFunctionDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalFunctionDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalFunctionDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalFunctionDefinition(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFunctionDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFunctionDefinition.cs new file mode 100644 index 000000000000..d1e082e988ad --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalFunctionDefinition.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for a function. + internal partial class InternalFunctionDefinition + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// 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 InternalFunctionDefinition(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 InternalFunctionDefinition(string name, string description, BinaryData parameters, IDictionary serializedAdditionalRawData) + { + Name = name; + Description = description; + Parameters = parameters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalFunctionDefinition() + { + } + + /// 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.Agents.Persistent/src/Generated/InternalMessageImageFileDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageImageFileDetails.Serialization.cs new file mode 100644 index 000000000000..87706c84891b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageImageFileDetails.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalMessageImageFileDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageImageFileDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(InternalDetails); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalMessageImageFileDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageImageFileDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageImageFileDetails(document.RootElement, options); + } + + internal static InternalMessageImageFileDetails DeserializeInternalMessageImageFileDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageImageFileDetails(fileId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageImageFileDetails)} does not support writing '{options.Format}' format."); + } + } + + InternalMessageImageFileDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalMessageImageFileDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageImageFileDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalMessageImageFileDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalMessageImageFileDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageImageFileDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageImageFileDetails.cs new file mode 100644 index 000000000000..0a790c2ce90f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageImageFileDetails.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// An image reference, as represented in thread message content. + internal partial class InternalMessageImageFileDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID for the file associated with this image. + /// is null. + internal InternalMessageImageFileDetails(string internalDetails) + { + Argument.AssertNotNull(internalDetails, nameof(internalDetails)); + + InternalDetails = internalDetails; + } + + /// Initializes a new instance of . + /// The ID for the file associated with this image. + /// Keeps track of any properties unknown to the library. + internal InternalMessageImageFileDetails(string internalDetails, IDictionary serializedAdditionalRawData) + { + InternalDetails = internalDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalMessageImageFileDetails() + { + } + + /// The ID for the file associated with this image. + public string InternalDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextDetails.Serialization.cs new file mode 100644 index 000000000000..f81ee3d4a48e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextDetails.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalMessageTextDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageTextDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Text); + writer.WritePropertyName("annotations"u8); + writer.WriteStartArray(); + foreach (var item in Annotations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalMessageTextDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageTextDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageTextDetails(document.RootElement, options); + } + + internal static InternalMessageTextDetails DeserializeInternalMessageTextDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + IReadOnlyList annotations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("annotations"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageTextAnnotation.DeserializeMessageTextAnnotation(item, options)); + } + annotations = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageTextDetails(value, annotations, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageTextDetails)} does not support writing '{options.Format}' format."); + } + } + + InternalMessageTextDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalMessageTextDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageTextDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalMessageTextDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalMessageTextDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextDetails.cs new file mode 100644 index 000000000000..42a61cb4b25d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextDetails.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The text and associated annotations for a single item of agent thread message content. + internal partial class InternalMessageTextDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The text data. + /// + /// A list of annotations associated with this text. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// or is null. + internal InternalMessageTextDetails(string text, IEnumerable annotations) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(annotations, nameof(annotations)); + + Text = text; + Annotations = annotations.ToList(); + } + + /// Initializes a new instance of . + /// The text data. + /// + /// A list of annotations associated with this text. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// Keeps track of any properties unknown to the library. + internal InternalMessageTextDetails(string text, IReadOnlyList annotations, IDictionary serializedAdditionalRawData) + { + Text = text; + Annotations = annotations; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalMessageTextDetails() + { + } + + /// The text data. + public string Text { get; } + /// + /// A list of annotations associated with this text. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public IReadOnlyList Annotations { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFileCitationDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFileCitationDetails.Serialization.cs new file mode 100644 index 000000000000..aac35a42a1be --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFileCitationDetails.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalMessageTextFileCitationDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageTextFileCitationDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + writer.WritePropertyName("quote"u8); + writer.WriteStringValue(Quote); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalMessageTextFileCitationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageTextFileCitationDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageTextFileCitationDetails(document.RootElement, options); + } + + internal static InternalMessageTextFileCitationDetails DeserializeInternalMessageTextFileCitationDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string quote = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("quote"u8)) + { + quote = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageTextFileCitationDetails(fileId, quote, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageTextFileCitationDetails)} does not support writing '{options.Format}' format."); + } + } + + InternalMessageTextFileCitationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalMessageTextFileCitationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageTextFileCitationDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalMessageTextFileCitationDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalMessageTextFileCitationDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFileCitationDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFileCitationDetails.cs new file mode 100644 index 000000000000..4ad49db9adf6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFileCitationDetails.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A representation of a file-based text citation, as used in a file-based annotation of text thread message content. + internal partial class InternalMessageTextFileCitationDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the file associated with this citation. + /// The specific quote cited in the associated file. + /// or is null. + internal InternalMessageTextFileCitationDetails(string fileId, string quote) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(quote, nameof(quote)); + + FileId = fileId; + Quote = quote; + } + + /// Initializes a new instance of . + /// The ID of the file associated with this citation. + /// The specific quote cited in the associated file. + /// Keeps track of any properties unknown to the library. + internal InternalMessageTextFileCitationDetails(string fileId, string quote, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Quote = quote; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalMessageTextFileCitationDetails() + { + } + + /// The ID of the file associated with this citation. + public string FileId { get; } + /// The specific quote cited in the associated file. + public string Quote { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFilePathDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFilePathDetails.Serialization.cs new file mode 100644 index 000000000000..2163ab3ade80 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFilePathDetails.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalMessageTextFilePathDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageTextFilePathDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalMessageTextFilePathDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageTextFilePathDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageTextFilePathDetails(document.RootElement, options); + } + + internal static InternalMessageTextFilePathDetails DeserializeInternalMessageTextFilePathDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageTextFilePathDetails(fileId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageTextFilePathDetails)} does not support writing '{options.Format}' format."); + } + } + + InternalMessageTextFilePathDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalMessageTextFilePathDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageTextFilePathDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalMessageTextFilePathDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalMessageTextFilePathDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFilePathDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFilePathDetails.cs new file mode 100644 index 000000000000..fb8a42c0275a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalMessageTextFilePathDetails.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// An encapsulation of an image file ID, as used by message image content. + internal partial class InternalMessageTextFilePathDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the specific file that the citation is from. + /// is null. + internal InternalMessageTextFilePathDetails(string fileId) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + } + + /// Initializes a new instance of . + /// The ID of the specific file that the citation is from. + /// Keeps track of any properties unknown to the library. + internal InternalMessageTextFilePathDetails(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalMessageTextFilePathDetails() + { + } + + /// The ID of the specific file that the citation is from. + public string FileId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRequiredFunctionToolCallDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRequiredFunctionToolCallDetails.Serialization.cs new file mode 100644 index 000000000000..85b7e7fe1d51 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRequiredFunctionToolCallDetails.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalRequiredFunctionToolCallDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCallDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalRequiredFunctionToolCallDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCallDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRequiredFunctionToolCallDetails(document.RootElement, options); + } + + internal static InternalRequiredFunctionToolCallDetails DeserializeInternalRequiredFunctionToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("arguments"u8)) + { + arguments = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRequiredFunctionToolCallDetails(name, arguments, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCallDetails)} does not support writing '{options.Format}' format."); + } + } + + InternalRequiredFunctionToolCallDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalRequiredFunctionToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCallDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalRequiredFunctionToolCallDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalRequiredFunctionToolCallDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRequiredFunctionToolCallDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRequiredFunctionToolCallDetails.cs new file mode 100644 index 000000000000..a2d8faa98f35 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRequiredFunctionToolCallDetails.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The detailed information for a function invocation, as provided by a required action invoking a function tool, that includes the name of and arguments to the function. + internal partial class InternalRequiredFunctionToolCallDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The name of the function. + /// The arguments to use when invoking the named function, as provided by the model. Arguments are presented as a JSON document that should be validated and parsed for evaluation. + /// or is null. + internal InternalRequiredFunctionToolCallDetails(string name, string arguments) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + Name = name; + Arguments = arguments; + } + + /// Initializes a new instance of . + /// The name of the function. + /// The arguments to use when invoking the named function, as provided by the model. Arguments are presented as a JSON document that should be validated and parsed for evaluation. + /// Keeps track of any properties unknown to the library. + internal InternalRequiredFunctionToolCallDetails(string name, string arguments, IDictionary serializedAdditionalRawData) + { + Name = name; + Arguments = arguments; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalRequiredFunctionToolCallDetails() + { + } + + /// The name of the function. + public string Name { get; } + /// The arguments to use when invoking the named function, as provided by the model. Arguments are presented as a JSON document that should be validated and parsed for evaluation. + public string Arguments { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRunStepFunctionToolCallDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRunStepFunctionToolCallDetails.Serialization.cs new file mode 100644 index 000000000000..63a4f782f344 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRunStepFunctionToolCallDetails.Serialization.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalRunStepFunctionToolCallDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + if (Output != null) + { + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + else + { + writer.WriteNull("output"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalRunStepFunctionToolCallDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement, options); + } + + internal static InternalRunStepFunctionToolCallDetails DeserializeInternalRunStepFunctionToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + string output = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("arguments"u8)) + { + arguments = property.Value.GetString(); + continue; + } + if (property.NameEquals("output"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + output = null; + continue; + } + output = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepFunctionToolCallDetails(name, arguments, output, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support writing '{options.Format}' format."); + } + } + + InternalRunStepFunctionToolCallDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalRunStepFunctionToolCallDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRunStepFunctionToolCallDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRunStepFunctionToolCallDetails.cs new file mode 100644 index 000000000000..a25e355ccf80 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalRunStepFunctionToolCallDetails.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The detailed information about the function called by the model. + internal partial class InternalRunStepFunctionToolCallDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The name of the function. + /// The arguments that the model requires are provided to the named function. + /// The output of the function, only populated for function calls that have already have had their outputs submitted. + /// or is null. + internal InternalRunStepFunctionToolCallDetails(string name, string arguments, string output) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + Name = name; + Arguments = arguments; + Output = output; + } + + /// Initializes a new instance of . + /// The name of the function. + /// The arguments that the model requires are provided to the named function. + /// The output of the function, only populated for function calls that have already have had their outputs submitted. + /// Keeps track of any properties unknown to the library. + internal InternalRunStepFunctionToolCallDetails(string name, string arguments, string output, IDictionary serializedAdditionalRawData) + { + Name = name; + Arguments = arguments; + Output = output; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalRunStepFunctionToolCallDetails() + { + } + + /// The name of the function. + public string Name { get; } + /// The arguments that the model requires are provided to the named function. + public string Arguments { get; } + /// The output of the function, only populated for function calls that have already have had their outputs submitted. + public string Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs new file mode 100644 index 000000000000..0b6713ec51b3 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class InternalSubmitToolOutputsDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalSubmitToolOutputsDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("tool_calls"u8); + writer.WriteStartArray(); + foreach (var item in ToolCalls) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + InternalSubmitToolOutputsDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalSubmitToolOutputsDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalSubmitToolOutputsDetails(document.RootElement, options); + } + + internal static InternalSubmitToolOutputsDetails DeserializeInternalSubmitToolOutputsDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList toolCalls = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_calls"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RequiredToolCall.DeserializeRequiredToolCall(item, options)); + } + toolCalls = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InternalSubmitToolOutputsDetails(toolCalls, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalSubmitToolOutputsDetails)} does not support writing '{options.Format}' format."); + } + } + + InternalSubmitToolOutputsDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalSubmitToolOutputsDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalSubmitToolOutputsDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InternalSubmitToolOutputsDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalSubmitToolOutputsDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalSubmitToolOutputsDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalSubmitToolOutputsDetails.cs new file mode 100644 index 000000000000..48c469214931 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/InternalSubmitToolOutputsDetails.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The details describing tools that should be called to submit tool outputs. + internal partial class InternalSubmitToolOutputsDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// The list of tool calls that must be resolved for the agent thread run to continue. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// is null. + internal InternalSubmitToolOutputsDetails(IEnumerable toolCalls) + { + Argument.AssertNotNull(toolCalls, nameof(toolCalls)); + + ToolCalls = toolCalls.ToList(); + } + + /// Initializes a new instance of . + /// + /// The list of tool calls that must be resolved for the agent thread run to continue. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// Keeps track of any properties unknown to the library. + internal InternalSubmitToolOutputsDetails(IReadOnlyList toolCalls, IDictionary serializedAdditionalRawData) + { + ToolCalls = toolCalls; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalSubmitToolOutputsDetails() + { + } + + /// + /// The list of tool calls that must be resolved for the agent thread run to continue. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public IReadOnlyList ToolCalls { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ListSortOrder.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ListSortOrder.cs new file mode 100644 index 000000000000..3428b4592ad2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ListSortOrder.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The available sorting options when requesting a list of response objects. + public readonly partial struct ListSortOrder : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ListSortOrder(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AscendingValue = "asc"; + private const string DescendingValue = "desc"; + + /// Specifies an ascending sort order. + public static ListSortOrder Ascending { get; } = new ListSortOrder(AscendingValue); + /// Specifies a descending sort order. + public static ListSortOrder Descending { get; } = new ListSortOrder(DescendingValue); + /// Determines if two values are the same. + public static bool operator ==(ListSortOrder left, ListSortOrder right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ListSortOrder left, ListSortOrder right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ListSortOrder(string value) => new ListSortOrder(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ListSortOrder other && Equals(other); + /// + public bool Equals(ListSortOrder 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.Agents.Persistent/src/Generated/MessageAttachment.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageAttachment.Serialization.cs new file mode 100644 index 000000000000..f80d17bc49c4 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageAttachment.Serialization.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageAttachment : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageAttachment)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (Optional.IsDefined(DataSource)) + { + writer.WritePropertyName("data_source"u8); + writer.WriteObjectValue(DataSource, options); + } + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item); +#else + using (JsonDocument document = JsonDocument.Parse(item, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageAttachment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageAttachment)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageAttachment(document.RootElement, options); + } + + internal static MessageAttachment DeserializeMessageAttachment(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + VectorStoreDataSource dataSource = default; + IList tools = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("data_source"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataSource = VectorStoreDataSource.DeserializeVectorStoreDataSource(property.Value, options); + continue; + } + if (property.NameEquals("tools"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(BinaryData.FromString(item.GetRawText())); + } + } + tools = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageAttachment(fileId, dataSource, tools, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageAttachment)} does not support writing '{options.Format}' format."); + } + } + + MessageAttachment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageAttachment(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageAttachment)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageAttachment FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageAttachment(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageAttachment.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageAttachment.cs new file mode 100644 index 000000000000..ec4296155e12 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageAttachment.cs @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// This describes to which tools a file has been attached. + public partial class MessageAttachment + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The tools to add to this file. + /// is null. + public MessageAttachment(IEnumerable tools) + { + Argument.AssertNotNull(tools, nameof(tools)); + + Tools = tools.ToList(); + } + + /// Initializes a new instance of . + /// The ID of the file to attach to the message. + /// Azure asset ID. + /// The tools to add to this file. + /// Keeps track of any properties unknown to the library. + internal MessageAttachment(string fileId, VectorStoreDataSource dataSource, IList tools, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + DataSource = dataSource; + Tools = tools; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageAttachment() + { + } + + /// The ID of the file to attach to the message. + public string FileId { get; set; } + /// Azure asset ID. + public VectorStoreDataSource DataSource { get; set; } + /// + /// The tools to add to this file. + /// + /// 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 Tools { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageBlockType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageBlockType.cs new file mode 100644 index 000000000000..2a5c2f5b5c6b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageBlockType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Specifies the kind of content block within a message. Could be text, an image file, an external image URL, or an unknown future type. + internal readonly partial struct MessageBlockType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageBlockType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TextValue = "text"; + private const string ImageFileValue = "image_file"; + private const string ImageUrlValue = "image_url"; + + /// Indicates a block containing text content. + public static MessageBlockType Text { get; } = new MessageBlockType(TextValue); + /// Indicates a block referencing an internally uploaded image file. + public static MessageBlockType ImageFile { get; } = new MessageBlockType(ImageFileValue); + /// Indicates a block referencing an external image URL. + public static MessageBlockType ImageUrl { get; } = new MessageBlockType(ImageUrlValue); + /// Determines if two values are the same. + public static bool operator ==(MessageBlockType left, MessageBlockType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageBlockType left, MessageBlockType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MessageBlockType(string value) => new MessageBlockType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageBlockType other && Equals(other); + /// + public bool Equals(MessageBlockType 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.Agents.Persistent/src/Generated/MessageContent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageContent.Serialization.cs new file mode 100644 index 000000000000..d6bbc1f95e13 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageContent.Serialization.cs @@ -0,0 +1,134 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownMessageContent))] + public partial class MessageContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageContent)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageContent(document.RootElement, options); + } + + internal static MessageContent DeserializeMessageContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "image_file": return MessageImageFileContent.DeserializeMessageImageFileContent(element, options); + case "text": return MessageTextContent.DeserializeMessageTextContent(element, options); + } + } + return UnknownMessageContent.DeserializeUnknownMessageContent(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageContent)} does not support writing '{options.Format}' format."); + } + } + + MessageContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageContent(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageContent.cs new file mode 100644 index 000000000000..a92110b78851 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageContent.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An abstract representation of a single item of thread message content. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class MessageContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected MessageContent() + { + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal MessageContent(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDelta.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDelta.Serialization.cs new file mode 100644 index 000000000000..15988b4f8da4 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDelta.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDelta : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDelta)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in Content) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDelta)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDelta(document.RootElement, options); + } + + internal static MessageDelta DeserializeMessageDelta(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageRole role = default; + IReadOnlyList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("role"u8)) + { + role = new MessageRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageDeltaContent.DeserializeMessageDeltaContent(item, options)); + } + content = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDelta(role, content, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDelta)} does not support writing '{options.Format}' format."); + } + } + + MessageDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDelta)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDelta FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDelta(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDelta.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDelta.cs new file mode 100644 index 000000000000..c71ff1ee0709 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDelta.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the typed 'delta' payload within a streaming message delta chunk. + public partial class MessageDelta + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The entity that produced the message. + /// + /// The content of the message as an array of text and/or images. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// is null. + internal MessageDelta(MessageRole role, IEnumerable content) + { + Argument.AssertNotNull(content, nameof(content)); + + Role = role; + Content = content.ToList(); + } + + /// Initializes a new instance of . + /// The entity that produced the message. + /// + /// The content of the message as an array of text and/or images. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal MessageDelta(MessageRole role, IReadOnlyList content, IDictionary serializedAdditionalRawData) + { + Role = role; + Content = content; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageDelta() + { + } + + /// The entity that produced the message. + public MessageRole Role { get; } + /// + /// The content of the message as an array of text and/or images. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public IReadOnlyList Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunk.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunk.Serialization.cs new file mode 100644 index 000000000000..bc557dc11ce9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunk.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaChunk : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaChunk)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("delta"u8); + writer.WriteObjectValue(Delta, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageDeltaChunk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaChunk)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaChunk(document.RootElement, options); + } + + internal static MessageDeltaChunk DeserializeMessageDeltaChunk(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + MessageDeltaChunkObject @object = default; + MessageDelta delta = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new MessageDeltaChunkObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("delta"u8)) + { + delta = MessageDelta.DeserializeMessageDelta(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaChunk(id, @object, delta, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaChunk)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaChunk IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaChunk(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaChunk)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaChunk FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaChunk(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunk.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunk.cs new file mode 100644 index 000000000000..26717e09935a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunk.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a message delta i.e. any changed fields on a message during streaming. + public partial class MessageDeltaChunk + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier of the message, which can be referenced in API endpoints. + /// The delta containing the fields that have changed on the Message. + /// or is null. + internal MessageDeltaChunk(string id, MessageDelta delta) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(delta, nameof(delta)); + + Id = id; + Delta = delta; + } + + /// Initializes a new instance of . + /// The identifier of the message, which can be referenced in API endpoints. + /// The object type, which is always `thread.message.delta`. + /// The delta containing the fields that have changed on the Message. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaChunk(string id, MessageDeltaChunkObject @object, MessageDelta delta, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + Delta = delta; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaChunk() + { + } + + /// The identifier of the message, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always `thread.message.delta`. + public MessageDeltaChunkObject Object { get; } = MessageDeltaChunkObject.ThreadMessageDelta; + + /// The delta containing the fields that have changed on the Message. + public MessageDelta Delta { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunkObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunkObject.cs new file mode 100644 index 000000000000..8e8154621340 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaChunkObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The MessageDeltaChunk_object. + public readonly partial struct MessageDeltaChunkObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageDeltaChunkObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadMessageDeltaValue = "thread.message.delta"; + + /// thread.message.delta. + public static MessageDeltaChunkObject ThreadMessageDelta { get; } = new MessageDeltaChunkObject(ThreadMessageDeltaValue); + /// Determines if two values are the same. + public static bool operator ==(MessageDeltaChunkObject left, MessageDeltaChunkObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageDeltaChunkObject left, MessageDeltaChunkObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MessageDeltaChunkObject(string value) => new MessageDeltaChunkObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageDeltaChunkObject other && Equals(other); + /// + public bool Equals(MessageDeltaChunkObject 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.Agents.Persistent/src/Generated/MessageDeltaContent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaContent.Serialization.cs new file mode 100644 index 000000000000..c38ad27a9f0f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaContent.Serialization.cs @@ -0,0 +1,136 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownMessageDeltaContent))] + public partial class MessageDeltaContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageDeltaContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaContent(document.RootElement, options); + } + + internal static MessageDeltaContent DeserializeMessageDeltaContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "image_file": return MessageDeltaImageFileContent.DeserializeMessageDeltaImageFileContent(element, options); + case "text": return MessageDeltaTextContent.DeserializeMessageDeltaTextContent(element, options); + } + } + return UnknownMessageDeltaContent.DeserializeUnknownMessageDeltaContent(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaContent(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaContent.cs new file mode 100644 index 000000000000..9ca7e6815fee --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaContent.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// The abstract base representation of a partial streamed message content payload. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class MessageDeltaContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The index of the content part of the message. + protected MessageDeltaContent(int index) + { + Index = index; + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The type of content for this content part. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaContent(int index, string type, IDictionary serializedAdditionalRawData) + { + Index = index; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaContent() + { + } + + /// The index of the content part of the message. + public int Index { get; } + /// The type of content for this content part. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContent.Serialization.cs new file mode 100644 index 000000000000..1aefc2c8e759 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContent.Serialization.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaImageFileContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaImageFileContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(ImageFile)) + { + writer.WritePropertyName("image_file"u8); + writer.WriteObjectValue(ImageFile, options); + } + } + + MessageDeltaImageFileContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaImageFileContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaImageFileContent(document.RootElement, options); + } + + internal static MessageDeltaImageFileContent DeserializeMessageDeltaImageFileContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageDeltaImageFileContentObject imageFile = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image_file"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + imageFile = MessageDeltaImageFileContentObject.DeserializeMessageDeltaImageFileContentObject(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaImageFileContent(index, type, serializedAdditionalRawData, imageFile); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaImageFileContent)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaImageFileContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaImageFileContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaImageFileContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageDeltaImageFileContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaImageFileContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContent.cs new file mode 100644 index 000000000000..09bd6b5a4417 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContent.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a streamed image file content part within a streaming message delta chunk. + public partial class MessageDeltaImageFileContent : MessageDeltaContent + { + /// Initializes a new instance of . + /// The index of the content part of the message. + internal MessageDeltaImageFileContent(int index) : base(index) + { + Type = "image_file"; + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The type of content for this content part. + /// Keeps track of any properties unknown to the library. + /// The image_file data. + internal MessageDeltaImageFileContent(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaImageFileContentObject imageFile) : base(index, type, serializedAdditionalRawData) + { + ImageFile = imageFile; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaImageFileContent() + { + } + + /// The image_file data. + public MessageDeltaImageFileContentObject ImageFile { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs new file mode 100644 index 000000000000..cf2e097418de --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaImageFileContentObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaImageFileContentObject)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageDeltaImageFileContentObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaImageFileContentObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaImageFileContentObject(document.RootElement, options); + } + + internal static MessageDeltaImageFileContentObject DeserializeMessageDeltaImageFileContentObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaImageFileContentObject(fileId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaImageFileContentObject)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaImageFileContentObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaImageFileContentObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaImageFileContentObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaImageFileContentObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaImageFileContentObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContentObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContentObject.cs new file mode 100644 index 000000000000..b31681416d6a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaImageFileContentObject.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the 'image_file' payload within streaming image file content. + public partial class MessageDeltaImageFileContentObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MessageDeltaImageFileContentObject() + { + } + + /// Initializes a new instance of . + /// The file ID of the image in the message content. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaImageFileContentObject(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The file ID of the image in the message content. + public string FileId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextAnnotation.Serialization.cs new file mode 100644 index 000000000000..0ae1e8e26ef4 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextAnnotation.Serialization.cs @@ -0,0 +1,137 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownMessageDeltaTextAnnotation))] + public partial class MessageDeltaTextAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageDeltaTextAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextAnnotation(document.RootElement, options); + } + + internal static MessageDeltaTextAnnotation DeserializeMessageDeltaTextAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "file_citation": return MessageDeltaTextFileCitationAnnotation.DeserializeMessageDeltaTextFileCitationAnnotation(element, options); + case "file_path": return MessageDeltaTextFilePathAnnotation.DeserializeMessageDeltaTextFilePathAnnotation(element, options); + case "url_citation": return MessageDeltaTextUrlCitationAnnotation.DeserializeMessageDeltaTextUrlCitationAnnotation(element, options); + } + } + return UnknownMessageDeltaTextAnnotation.DeserializeUnknownMessageDeltaTextAnnotation(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaTextAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextAnnotation(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextAnnotation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextAnnotation.cs new file mode 100644 index 000000000000..fcef4cd14062 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextAnnotation.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// The abstract base representation of a streamed text content part's text annotation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class MessageDeltaTextAnnotation + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + protected MessageDeltaTextAnnotation(int index) + { + Index = index; + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaTextAnnotation(int index, string type, IDictionary serializedAdditionalRawData) + { + Index = index; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaTextAnnotation() + { + } + + /// The index of the annotation within a text content part. + public int Index { get; } + /// The type of the text content annotation. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContent.Serialization.cs new file mode 100644 index 000000000000..dc9f18c61d42 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContent.Serialization.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaTextContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteObjectValue(Text, options); + } + } + + MessageDeltaTextContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextContent(document.RootElement, options); + } + + internal static MessageDeltaTextContent DeserializeMessageDeltaTextContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageDeltaTextContentObject text = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + text = MessageDeltaTextContentObject.DeserializeMessageDeltaTextContentObject(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextContent(index, type, serializedAdditionalRawData, text); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextContent)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageDeltaTextContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContent.cs new file mode 100644 index 000000000000..c27bb8464a2c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContent.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a streamed text content part within a streaming message delta chunk. + public partial class MessageDeltaTextContent : MessageDeltaContent + { + /// Initializes a new instance of . + /// The index of the content part of the message. + internal MessageDeltaTextContent(int index) : base(index) + { + Type = "text"; + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The type of content for this content part. + /// Keeps track of any properties unknown to the library. + /// The text content details. + internal MessageDeltaTextContent(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextContentObject text) : base(index, type, serializedAdditionalRawData) + { + Text = text; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaTextContent() + { + } + + /// The text content details. + public MessageDeltaTextContentObject Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContentObject.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContentObject.Serialization.cs new file mode 100644 index 000000000000..37f7ef15bf41 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContentObject.Serialization.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaTextContentObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (Optional.IsCollectionDefined(Annotations)) + { + writer.WritePropertyName("annotations"u8); + writer.WriteStartArray(); + foreach (var item in Annotations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageDeltaTextContentObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextContentObject(document.RootElement, options); + } + + internal static MessageDeltaTextContentObject DeserializeMessageDeltaTextContentObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + IReadOnlyList annotations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("annotations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageDeltaTextAnnotation.DeserializeMessageDeltaTextAnnotation(item, options)); + } + annotations = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextContentObject(value, annotations ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextContentObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextContentObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaTextContentObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextContentObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContentObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContentObject.cs new file mode 100644 index 000000000000..2b202bd13261 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextContentObject.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the data of a streamed text content part within a streaming message delta chunk. + public partial class MessageDeltaTextContentObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MessageDeltaTextContentObject() + { + Annotations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The data that makes up the text. + /// + /// Annotations for the text. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// Keeps track of any properties unknown to the library. + internal MessageDeltaTextContentObject(string value, IReadOnlyList annotations, IDictionary serializedAdditionalRawData) + { + Value = value; + Annotations = annotations; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The data that makes up the text. + public string Value { get; } + /// + /// Annotations for the text. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public IReadOnlyList Annotations { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs new file mode 100644 index 000000000000..35463a567181 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaTextFileCitationAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotation)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(FileCitation)) + { + writer.WritePropertyName("file_citation"u8); + writer.WriteObjectValue(FileCitation, options); + } + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } + } + + MessageDeltaTextFileCitationAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextFileCitationAnnotation(document.RootElement, options); + } + + internal static MessageDeltaTextFileCitationAnnotation DeserializeMessageDeltaTextFileCitationAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageDeltaTextFileCitationAnnotationObject fileCitation = default; + string text = default; + int? startIndex = default; + int? endIndex = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_citation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileCitation = MessageDeltaTextFileCitationAnnotationObject.DeserializeMessageDeltaTextFileCitationAnnotationObject(property.Value, options); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("start_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextFileCitationAnnotation( + index, + type, + serializedAdditionalRawData, + fileCitation, + text, + startIndex, + endIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextFileCitationAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextFileCitationAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageDeltaTextFileCitationAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextFileCitationAnnotation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotation.cs new file mode 100644 index 000000000000..5e833ebc63bb --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotation.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a streamed file citation applied to a streaming text content part. + public partial class MessageDeltaTextFileCitationAnnotation : MessageDeltaTextAnnotation + { + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + internal MessageDeltaTextFileCitationAnnotation(int index) : base(index) + { + Type = "file_citation"; + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// Keeps track of any properties unknown to the library. + /// The file citation information. + /// The text in the message content that needs to be replaced. + /// The start index of this annotation in the content text. + /// The end index of this annotation in the content text. + internal MessageDeltaTextFileCitationAnnotation(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextFileCitationAnnotationObject fileCitation, string text, int? startIndex, int? endIndex) : base(index, type, serializedAdditionalRawData) + { + FileCitation = fileCitation; + Text = text; + StartIndex = startIndex; + EndIndex = endIndex; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaTextFileCitationAnnotation() + { + } + + /// The file citation information. + public MessageDeltaTextFileCitationAnnotationObject FileCitation { get; } + /// The text in the message content that needs to be replaced. + public string Text { get; } + /// The start index of this annotation in the content text. + public int? StartIndex { get; } + /// The end index of this annotation in the content text. + public int? EndIndex { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs new file mode 100644 index 000000000000..ba294c985605 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaTextFileCitationAnnotationObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotationObject)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (Optional.IsDefined(Quote)) + { + writer.WritePropertyName("quote"u8); + writer.WriteStringValue(Quote); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageDeltaTextFileCitationAnnotationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotationObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextFileCitationAnnotationObject(document.RootElement, options); + } + + internal static MessageDeltaTextFileCitationAnnotationObject DeserializeMessageDeltaTextFileCitationAnnotationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string quote = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("quote"u8)) + { + quote = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextFileCitationAnnotationObject(fileId, quote, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotationObject)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextFileCitationAnnotationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextFileCitationAnnotationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotationObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaTextFileCitationAnnotationObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextFileCitationAnnotationObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotationObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotationObject.cs new file mode 100644 index 000000000000..99189ef2dce3 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFileCitationAnnotationObject.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the data of a streamed file citation as applied to a streaming text content part. + public partial class MessageDeltaTextFileCitationAnnotationObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MessageDeltaTextFileCitationAnnotationObject() + { + } + + /// Initializes a new instance of . + /// The ID of the specific file the citation is from. + /// The specific quote in the cited file. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaTextFileCitationAnnotationObject(string fileId, string quote, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Quote = quote; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The ID of the specific file the citation is from. + public string FileId { get; } + /// The specific quote in the cited file. + public string Quote { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs new file mode 100644 index 000000000000..130414a30160 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaTextFilePathAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotation)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(FilePath)) + { + writer.WritePropertyName("file_path"u8); + writer.WriteObjectValue(FilePath, options); + } + if (Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + } + + MessageDeltaTextFilePathAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextFilePathAnnotation(document.RootElement, options); + } + + internal static MessageDeltaTextFilePathAnnotation DeserializeMessageDeltaTextFilePathAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageDeltaTextFilePathAnnotationObject filePath = default; + int? startIndex = default; + int? endIndex = default; + string text = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_path"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + filePath = MessageDeltaTextFilePathAnnotationObject.DeserializeMessageDeltaTextFilePathAnnotationObject(property.Value, options); + continue; + } + if (property.NameEquals("start_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextFilePathAnnotation( + index, + type, + serializedAdditionalRawData, + filePath, + startIndex, + endIndex, + text); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextFilePathAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextFilePathAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageDeltaTextFilePathAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextFilePathAnnotation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotation.cs new file mode 100644 index 000000000000..21dd5fa1846f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotation.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a streamed file path annotation applied to a streaming text content part. + public partial class MessageDeltaTextFilePathAnnotation : MessageDeltaTextAnnotation + { + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + internal MessageDeltaTextFilePathAnnotation(int index) : base(index) + { + Type = "file_path"; + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// Keeps track of any properties unknown to the library. + /// The file path information. + /// The start index of this annotation in the content text. + /// The end index of this annotation in the content text. + /// The text in the message content that needs to be replaced. + internal MessageDeltaTextFilePathAnnotation(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextFilePathAnnotationObject filePath, int? startIndex, int? endIndex, string text) : base(index, type, serializedAdditionalRawData) + { + FilePath = filePath; + StartIndex = startIndex; + EndIndex = endIndex; + Text = text; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaTextFilePathAnnotation() + { + } + + /// The file path information. + public MessageDeltaTextFilePathAnnotationObject FilePath { get; } + /// The start index of this annotation in the content text. + public int? StartIndex { get; } + /// The end index of this annotation in the content text. + public int? EndIndex { get; } + /// The text in the message content that needs to be replaced. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs new file mode 100644 index 000000000000..81ed2af022a6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaTextFilePathAnnotationObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotationObject)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageDeltaTextFilePathAnnotationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotationObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextFilePathAnnotationObject(document.RootElement, options); + } + + internal static MessageDeltaTextFilePathAnnotationObject DeserializeMessageDeltaTextFilePathAnnotationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextFilePathAnnotationObject(fileId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotationObject)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextFilePathAnnotationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextFilePathAnnotationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotationObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaTextFilePathAnnotationObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextFilePathAnnotationObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotationObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotationObject.cs new file mode 100644 index 000000000000..ee2e7353bee9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextFilePathAnnotationObject.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the data of a streamed file path annotation as applied to a streaming text content part. + public partial class MessageDeltaTextFilePathAnnotationObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MessageDeltaTextFilePathAnnotationObject() + { + } + + /// Initializes a new instance of . + /// The file ID for the annotation. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaTextFilePathAnnotationObject(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The file ID for the annotation. + public string FileId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationAnnotation.Serialization.cs new file mode 100644 index 000000000000..6d4fed044209 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationAnnotation.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaTextUrlCitationAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationAnnotation)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("url_citation"u8); + writer.WriteObjectValue(UrlCitation, options); + if (Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } + } + + MessageDeltaTextUrlCitationAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextUrlCitationAnnotation(document.RootElement, options); + } + + internal static MessageDeltaTextUrlCitationAnnotation DeserializeMessageDeltaTextUrlCitationAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageDeltaTextUrlCitationDetails urlCitation = default; + int? startIndex = default; + int? endIndex = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url_citation"u8)) + { + urlCitation = MessageDeltaTextUrlCitationDetails.DeserializeMessageDeltaTextUrlCitationDetails(property.Value, options); + continue; + } + if (property.NameEquals("start_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextUrlCitationAnnotation( + index, + type, + serializedAdditionalRawData, + urlCitation, + startIndex, + endIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextUrlCitationAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextUrlCitationAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageDeltaTextUrlCitationAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextUrlCitationAnnotation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationAnnotation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationAnnotation.cs new file mode 100644 index 000000000000..6a4c7d0f7248 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationAnnotation.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A citation within the message that points to a specific URL associated with the message. Generated when the agent uses tools such as 'bing_grounding' to search the Internet. + public partial class MessageDeltaTextUrlCitationAnnotation : MessageDeltaTextAnnotation + { + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The details of the URL citation. + /// is null. + internal MessageDeltaTextUrlCitationAnnotation(int index, MessageDeltaTextUrlCitationDetails urlCitation) : base(index) + { + Argument.AssertNotNull(urlCitation, nameof(urlCitation)); + + Type = "url_citation"; + UrlCitation = urlCitation; + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// Keeps track of any properties unknown to the library. + /// The details of the URL citation. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + internal MessageDeltaTextUrlCitationAnnotation(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextUrlCitationDetails urlCitation, int? startIndex, int? endIndex) : base(index, type, serializedAdditionalRawData) + { + UrlCitation = urlCitation; + StartIndex = startIndex; + EndIndex = endIndex; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaTextUrlCitationAnnotation() + { + } + + /// The details of the URL citation. + public MessageDeltaTextUrlCitationDetails UrlCitation { get; } + /// The first text index associated with this text annotation. + public int? StartIndex { get; } + /// The last text index associated with this text annotation. + public int? EndIndex { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationDetails.Serialization.cs new file mode 100644 index 000000000000..2419ceca047c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationDetails.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageDeltaTextUrlCitationDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url); + if (Optional.IsDefined(Title)) + { + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageDeltaTextUrlCitationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextUrlCitationDetails(document.RootElement, options); + } + + internal static MessageDeltaTextUrlCitationDetails DeserializeMessageDeltaTextUrlCitationDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string url = default; + string title = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url"u8)) + { + url = property.Value.GetString(); + continue; + } + if (property.NameEquals("title"u8)) + { + title = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextUrlCitationDetails(url, title, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationDetails)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextUrlCitationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextUrlCitationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextUrlCitationDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaTextUrlCitationDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextUrlCitationDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationDetails.cs new file mode 100644 index 000000000000..2a84a9ab4d74 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageDeltaTextUrlCitationDetails.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A representation of a URL citation, as used in text thread message content. + public partial class MessageDeltaTextUrlCitationDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The URL associated with this citation. + /// is null. + internal MessageDeltaTextUrlCitationDetails(string url) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + /// Initializes a new instance of . + /// The URL associated with this citation. + /// The title of the URL. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaTextUrlCitationDetails(string url, string title, IDictionary serializedAdditionalRawData) + { + Url = url; + Title = title; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaTextUrlCitationDetails() + { + } + + /// The URL associated with this citation. + public string Url { get; } + /// The title of the URL. + public string Title { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileContent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileContent.Serialization.cs new file mode 100644 index 000000000000..cf3ef60e11d7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileContent.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageImageFileContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageImageFileContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("image_file"u8); + writer.WriteObjectValue(InternalDetails, options); + } + + MessageImageFileContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageImageFileContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageImageFileContent(document.RootElement, options); + } + + internal static MessageImageFileContent DeserializeMessageImageFileContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMessageImageFileDetails imageFile = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image_file"u8)) + { + imageFile = InternalMessageImageFileDetails.DeserializeInternalMessageImageFileDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageImageFileContent(type, serializedAdditionalRawData, imageFile); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageImageFileContent)} does not support writing '{options.Format}' format."); + } + } + + MessageImageFileContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageImageFileContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageImageFileContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageImageFileContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageImageFileContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileContent.cs new file mode 100644 index 000000000000..d40125445e26 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileContent.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A representation of image file content in a thread message. + public partial class MessageImageFileContent : MessageContent + { + /// Initializes a new instance of . + /// The image file for this thread message content item. + /// is null. + internal MessageImageFileContent(InternalMessageImageFileDetails internalDetails) + { + Argument.AssertNotNull(internalDetails, nameof(internalDetails)); + + Type = "image_file"; + InternalDetails = internalDetails; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The image file for this thread message content item. + internal MessageImageFileContent(string type, IDictionary serializedAdditionalRawData, InternalMessageImageFileDetails internalDetails) : base(type, serializedAdditionalRawData) + { + InternalDetails = internalDetails; + } + + /// Initializes a new instance of for deserialization. + internal MessageImageFileContent() + { + } + + /// The image file for this thread message content item. + public InternalMessageImageFileDetails InternalDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileParam.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileParam.Serialization.cs new file mode 100644 index 000000000000..3c398dbf5497 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileParam.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageImageFileParam : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageImageFileParam)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + if (Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageImageFileParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageImageFileParam)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageImageFileParam(document.RootElement, options); + } + + internal static MessageImageFileParam DeserializeMessageImageFileParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + ImageDetailLevel? detail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("detail"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + detail = new ImageDetailLevel(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageImageFileParam(fileId, detail, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageImageFileParam)} does not support writing '{options.Format}' format."); + } + } + + MessageImageFileParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageImageFileParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageImageFileParam)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageImageFileParam FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageImageFileParam(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileParam.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileParam.cs new file mode 100644 index 000000000000..11eec8730a99 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageFileParam.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Defines how an internally uploaded image file is referenced when creating an image-file block. + public partial class MessageImageFileParam + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the previously uploaded image file. + /// is null. + public MessageImageFileParam(string fileId) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + } + + /// Initializes a new instance of . + /// The ID of the previously uploaded image file. + /// Optional detail level for the image (auto, low, or high). + /// Keeps track of any properties unknown to the library. + internal MessageImageFileParam(string fileId, ImageDetailLevel? detail, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Detail = detail; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageImageFileParam() + { + } + + /// The ID of the previously uploaded image file. + public string FileId { get; } + /// Optional detail level for the image (auto, low, or high). + public ImageDetailLevel? Detail { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageUrlParam.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageUrlParam.Serialization.cs new file mode 100644 index 000000000000..8a87585d4ec4 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageUrlParam.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageImageUrlParam : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageImageUrlParam)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url); + if (Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageImageUrlParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageImageUrlParam)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageImageUrlParam(document.RootElement, options); + } + + internal static MessageImageUrlParam DeserializeMessageImageUrlParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string url = default; + ImageDetailLevel? detail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url"u8)) + { + url = property.Value.GetString(); + continue; + } + if (property.NameEquals("detail"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + detail = new ImageDetailLevel(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageImageUrlParam(url, detail, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageImageUrlParam)} does not support writing '{options.Format}' format."); + } + } + + MessageImageUrlParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageImageUrlParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageImageUrlParam)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageImageUrlParam FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageImageUrlParam(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageUrlParam.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageUrlParam.cs new file mode 100644 index 000000000000..cccd2a2cfd8d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageImageUrlParam.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Defines how an external image URL is referenced when creating an image-URL block. + public partial class MessageImageUrlParam + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The publicly accessible URL of the external image. + /// is null. + public MessageImageUrlParam(string url) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + /// Initializes a new instance of . + /// The publicly accessible URL of the external image. + /// Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. + /// Keeps track of any properties unknown to the library. + internal MessageImageUrlParam(string url, ImageDetailLevel? detail, IDictionary serializedAdditionalRawData) + { + Url = url; + Detail = detail; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageImageUrlParam() + { + } + + /// The publicly accessible URL of the external image. + public string Url { get; } + /// Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. + public ImageDetailLevel? Detail { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetails.Serialization.cs new file mode 100644 index 000000000000..364a6a97de9a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetails.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageIncompleteDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageIncompleteDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageIncompleteDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageIncompleteDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageIncompleteDetails(document.RootElement, options); + } + + internal static MessageIncompleteDetails DeserializeMessageIncompleteDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageIncompleteDetailsReason reason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("reason"u8)) + { + reason = new MessageIncompleteDetailsReason(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageIncompleteDetails(reason, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageIncompleteDetails)} does not support writing '{options.Format}' format."); + } + } + + MessageIncompleteDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageIncompleteDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageIncompleteDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageIncompleteDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageIncompleteDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetails.cs new file mode 100644 index 000000000000..d4a2d1ae4a84 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetails.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Information providing additional detail about a message entering an incomplete status. + public partial class MessageIncompleteDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The provided reason describing why the message was marked as incomplete. + internal MessageIncompleteDetails(MessageIncompleteDetailsReason reason) + { + Reason = reason; + } + + /// Initializes a new instance of . + /// The provided reason describing why the message was marked as incomplete. + /// Keeps track of any properties unknown to the library. + internal MessageIncompleteDetails(MessageIncompleteDetailsReason reason, IDictionary serializedAdditionalRawData) + { + Reason = reason; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageIncompleteDetails() + { + } + + /// The provided reason describing why the message was marked as incomplete. + public MessageIncompleteDetailsReason Reason { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetailsReason.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetailsReason.cs new file mode 100644 index 000000000000..4d301fa769e6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageIncompleteDetailsReason.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// A set of reasons describing why a message is marked as incomplete. + public readonly partial struct MessageIncompleteDetailsReason : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageIncompleteDetailsReason(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ContentFilterValue = "content_filter"; + private const string MaxTokensValue = "max_tokens"; + private const string RunCancelledValue = "run_cancelled"; + private const string RunFailedValue = "run_failed"; + private const string RunExpiredValue = "run_expired"; + + /// The run generating the message was terminated due to content filter flagging. + public static MessageIncompleteDetailsReason ContentFilter { get; } = new MessageIncompleteDetailsReason(ContentFilterValue); + /// The run generating the message exhausted available tokens before completion. + public static MessageIncompleteDetailsReason MaxTokens { get; } = new MessageIncompleteDetailsReason(MaxTokensValue); + /// The run generating the message was cancelled before completion. + public static MessageIncompleteDetailsReason RunCancelled { get; } = new MessageIncompleteDetailsReason(RunCancelledValue); + /// The run generating the message failed. + public static MessageIncompleteDetailsReason RunFailed { get; } = new MessageIncompleteDetailsReason(RunFailedValue); + /// The run generating the message expired. + public static MessageIncompleteDetailsReason RunExpired { get; } = new MessageIncompleteDetailsReason(RunExpiredValue); + /// Determines if two values are the same. + public static bool operator ==(MessageIncompleteDetailsReason left, MessageIncompleteDetailsReason right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageIncompleteDetailsReason left, MessageIncompleteDetailsReason right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MessageIncompleteDetailsReason(string value) => new MessageIncompleteDetailsReason(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageIncompleteDetailsReason other && Equals(other); + /// + public bool Equals(MessageIncompleteDetailsReason 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.Agents.Persistent/src/Generated/MessageInputContentBlock.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputContentBlock.Serialization.cs new file mode 100644 index 000000000000..cf49a61a2cad --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputContentBlock.Serialization.cs @@ -0,0 +1,135 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownMessageInputContentBlock))] + public partial class MessageInputContentBlock : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageInputContentBlock IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageInputContentBlock(document.RootElement, options); + } + + internal static MessageInputContentBlock DeserializeMessageInputContentBlock(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "image_file": return MessageInputImageFileBlock.DeserializeMessageInputImageFileBlock(element, options); + case "image_url": return MessageInputImageUrlBlock.DeserializeMessageInputImageUrlBlock(element, options); + case "text": return MessageInputTextBlock.DeserializeMessageInputTextBlock(element, options); + } + } + return UnknownMessageInputContentBlock.DeserializeUnknownMessageInputContentBlock(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support writing '{options.Format}' format."); + } + } + + MessageInputContentBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputContentBlock(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageInputContentBlock FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputContentBlock(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputContentBlock.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputContentBlock.cs new file mode 100644 index 000000000000..463760040420 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputContentBlock.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// Defines a single content block when creating a message. The 'type' field determines whether it is text, an image file, or an external image URL, etc. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class MessageInputContentBlock + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected MessageInputContentBlock() + { + } + + /// Initializes a new instance of . + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + /// Keeps track of any properties unknown to the library. + internal MessageInputContentBlock(MessageBlockType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + internal MessageBlockType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageFileBlock.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageFileBlock.Serialization.cs new file mode 100644 index 000000000000..fd6140e1edb2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageFileBlock.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageInputImageFileBlock : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputImageFileBlock)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("image_file"u8); + writer.WriteObjectValue(ImageFile, options); + } + + MessageInputImageFileBlock IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputImageFileBlock)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageInputImageFileBlock(document.RootElement, options); + } + + internal static MessageInputImageFileBlock DeserializeMessageInputImageFileBlock(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageImageFileParam imageFile = default; + MessageBlockType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image_file"u8)) + { + imageFile = MessageImageFileParam.DeserializeMessageImageFileParam(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new MessageBlockType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageInputImageFileBlock(type, serializedAdditionalRawData, imageFile); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageInputImageFileBlock)} does not support writing '{options.Format}' format."); + } + } + + MessageInputImageFileBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputImageFileBlock(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageInputImageFileBlock)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageInputImageFileBlock FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputImageFileBlock(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageFileBlock.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageFileBlock.cs new file mode 100644 index 000000000000..991fe837af4f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageFileBlock.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// An image-file block in a new message, referencing an internally uploaded image by file ID. + public partial class MessageInputImageFileBlock : MessageInputContentBlock + { + /// Initializes a new instance of . + /// Information about the referenced image file, including file ID and optional detail level. + /// is null. + public MessageInputImageFileBlock(MessageImageFileParam imageFile) + { + Argument.AssertNotNull(imageFile, nameof(imageFile)); + + Type = MessageBlockType.ImageFile; + ImageFile = imageFile; + } + + /// Initializes a new instance of . + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + /// Keeps track of any properties unknown to the library. + /// Information about the referenced image file, including file ID and optional detail level. + internal MessageInputImageFileBlock(MessageBlockType type, IDictionary serializedAdditionalRawData, MessageImageFileParam imageFile) : base(type, serializedAdditionalRawData) + { + ImageFile = imageFile; + } + + /// Initializes a new instance of for deserialization. + internal MessageInputImageFileBlock() + { + } + + /// Information about the referenced image file, including file ID and optional detail level. + public MessageImageFileParam ImageFile { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageUrlBlock.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageUrlBlock.Serialization.cs new file mode 100644 index 000000000000..4df4443e7c2d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageUrlBlock.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageInputImageUrlBlock : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputImageUrlBlock)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("image_url"u8); + writer.WriteObjectValue(ImageUrl, options); + } + + MessageInputImageUrlBlock IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputImageUrlBlock)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageInputImageUrlBlock(document.RootElement, options); + } + + internal static MessageInputImageUrlBlock DeserializeMessageInputImageUrlBlock(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageImageUrlParam imageUrl = default; + MessageBlockType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image_url"u8)) + { + imageUrl = MessageImageUrlParam.DeserializeMessageImageUrlParam(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new MessageBlockType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageInputImageUrlBlock(type, serializedAdditionalRawData, imageUrl); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageInputImageUrlBlock)} does not support writing '{options.Format}' format."); + } + } + + MessageInputImageUrlBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputImageUrlBlock(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageInputImageUrlBlock)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageInputImageUrlBlock FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputImageUrlBlock(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageUrlBlock.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageUrlBlock.cs new file mode 100644 index 000000000000..26dc7c9e35c7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputImageUrlBlock.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// An image-URL block in a new message, referencing an external image by URL. + public partial class MessageInputImageUrlBlock : MessageInputContentBlock + { + /// Initializes a new instance of . + /// Information about the external image URL, including the URL and optional detail level. + /// is null. + public MessageInputImageUrlBlock(MessageImageUrlParam imageUrl) + { + Argument.AssertNotNull(imageUrl, nameof(imageUrl)); + + Type = MessageBlockType.ImageUrl; + ImageUrl = imageUrl; + } + + /// Initializes a new instance of . + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + /// Keeps track of any properties unknown to the library. + /// Information about the external image URL, including the URL and optional detail level. + internal MessageInputImageUrlBlock(MessageBlockType type, IDictionary serializedAdditionalRawData, MessageImageUrlParam imageUrl) : base(type, serializedAdditionalRawData) + { + ImageUrl = imageUrl; + } + + /// Initializes a new instance of for deserialization. + internal MessageInputImageUrlBlock() + { + } + + /// Information about the external image URL, including the URL and optional detail level. + public MessageImageUrlParam ImageUrl { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputTextBlock.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputTextBlock.Serialization.cs new file mode 100644 index 000000000000..19fb65af70db --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputTextBlock.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageInputTextBlock : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputTextBlock)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + + MessageInputTextBlock IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputTextBlock)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageInputTextBlock(document.RootElement, options); + } + + internal static MessageInputTextBlock DeserializeMessageInputTextBlock(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + MessageBlockType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new MessageBlockType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageInputTextBlock(type, serializedAdditionalRawData, text); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageInputTextBlock)} does not support writing '{options.Format}' format."); + } + } + + MessageInputTextBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputTextBlock(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageInputTextBlock)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageInputTextBlock FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputTextBlock(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputTextBlock.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputTextBlock.cs new file mode 100644 index 000000000000..9dbb9ae09500 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageInputTextBlock.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A text block in a new message, containing plain text content. + public partial class MessageInputTextBlock : MessageInputContentBlock + { + /// Initializes a new instance of . + /// The plain text content for this block. + /// is null. + public MessageInputTextBlock(string text) + { + Argument.AssertNotNull(text, nameof(text)); + + Type = MessageBlockType.Text; + Text = text; + } + + /// Initializes a new instance of . + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + /// Keeps track of any properties unknown to the library. + /// The plain text content for this block. + internal MessageInputTextBlock(MessageBlockType type, IDictionary serializedAdditionalRawData, string text) : base(type, serializedAdditionalRawData) + { + Text = text; + } + + /// Initializes a new instance of for deserialization. + internal MessageInputTextBlock() + { + } + + /// The plain text content for this block. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageRole.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageRole.cs new file mode 100644 index 000000000000..abb1bfbbf763 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageRole.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The possible values for roles attributed to messages in a thread. + public readonly partial struct MessageRole : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageRole(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UserValue = "user"; + private const string AgentValue = "assistant"; + + /// The role representing the end-user. + public static MessageRole User { get; } = new MessageRole(UserValue); + /// The role representing the agent. + public static MessageRole Agent { get; } = new MessageRole(AgentValue); + /// Determines if two values are the same. + public static bool operator ==(MessageRole left, MessageRole right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageRole left, MessageRole right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MessageRole(string value) => new MessageRole(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageRole other && Equals(other); + /// + public bool Equals(MessageRole 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.Agents.Persistent/src/Generated/MessageStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageStatus.cs new file mode 100644 index 000000000000..c40ff576c9fc --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageStatus.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The possible execution status values for a thread message. + public readonly partial struct MessageStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "in_progress"; + private const string IncompleteValue = "incomplete"; + private const string CompletedValue = "completed"; + + /// A run is currently creating this message. + public static MessageStatus InProgress { get; } = new MessageStatus(InProgressValue); + /// This message is incomplete. See incomplete_details for more information. + public static MessageStatus Incomplete { get; } = new MessageStatus(IncompleteValue); + /// This message was successfully completed by a run. + public static MessageStatus Completed { get; } = new MessageStatus(CompletedValue); + /// Determines if two values are the same. + public static bool operator ==(MessageStatus left, MessageStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageStatus left, MessageStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MessageStatus(string value) => new MessageStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageStatus other && Equals(other); + /// + public bool Equals(MessageStatus 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.Agents.Persistent/src/Generated/MessageStreamEvent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageStreamEvent.cs new file mode 100644 index 000000000000..73fba226628c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageStreamEvent.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Message operation related streaming events. + public readonly partial struct MessageStreamEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageStreamEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadMessageCreatedValue = "thread.message.created"; + private const string ThreadMessageInProgressValue = "thread.message.in_progress"; + private const string ThreadMessageDeltaValue = "thread.message.delta"; + private const string ThreadMessageCompletedValue = "thread.message.completed"; + private const string ThreadMessageIncompleteValue = "thread.message.incomplete"; + + /// Event sent when a new message is created. The data of this event is of type ThreadMessage. + public static MessageStreamEvent ThreadMessageCreated { get; } = new MessageStreamEvent(ThreadMessageCreatedValue); + /// Event sent when a message moves to `in_progress` status. The data of this event is of type ThreadMessage. + public static MessageStreamEvent ThreadMessageInProgress { get; } = new MessageStreamEvent(ThreadMessageInProgressValue); + /// Event sent when a message is being streamed. The data of this event is of type MessageDeltaChunk. + public static MessageStreamEvent ThreadMessageDelta { get; } = new MessageStreamEvent(ThreadMessageDeltaValue); + /// Event sent when a message is completed. The data of this event is of type ThreadMessage. + public static MessageStreamEvent ThreadMessageCompleted { get; } = new MessageStreamEvent(ThreadMessageCompletedValue); + /// Event sent before a message is completed. The data of this event is of type ThreadMessage. + public static MessageStreamEvent ThreadMessageIncomplete { get; } = new MessageStreamEvent(ThreadMessageIncompleteValue); + /// Determines if two values are the same. + public static bool operator ==(MessageStreamEvent left, MessageStreamEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageStreamEvent left, MessageStreamEvent right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MessageStreamEvent(string value) => new MessageStreamEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageStreamEvent other && Equals(other); + /// + public bool Equals(MessageStreamEvent 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.Agents.Persistent/src/Generated/MessageTextAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextAnnotation.Serialization.cs new file mode 100644 index 000000000000..4047a1b6fe94 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextAnnotation.Serialization.cs @@ -0,0 +1,137 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownMessageTextAnnotation))] + public partial class MessageTextAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageTextAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextAnnotation(document.RootElement, options); + } + + internal static MessageTextAnnotation DeserializeMessageTextAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "file_citation": return MessageTextFileCitationAnnotation.DeserializeMessageTextFileCitationAnnotation(element, options); + case "file_path": return MessageTextFilePathAnnotation.DeserializeMessageTextFilePathAnnotation(element, options); + case "url_citation": return MessageTextUrlCitationAnnotation.DeserializeMessageTextUrlCitationAnnotation(element, options); + } + } + return UnknownMessageTextAnnotation.DeserializeUnknownMessageTextAnnotation(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageTextAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageTextAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextAnnotation(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextAnnotation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextAnnotation.cs new file mode 100644 index 000000000000..94824f160c89 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextAnnotation.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An abstract representation of an annotation to text thread message content. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class MessageTextAnnotation + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The textual content associated with this text annotation item. + /// is null. + protected MessageTextAnnotation(string text) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Initializes a new instance of . + /// The object type. + /// The textual content associated with this text annotation item. + /// Keeps track of any properties unknown to the library. + internal MessageTextAnnotation(string type, string text, IDictionary serializedAdditionalRawData) + { + Type = type; + Text = text; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageTextAnnotation() + { + } + + /// The object type. + internal string Type { get; set; } + /// The textual content associated with this text annotation item. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextContent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextContent.Serialization.cs new file mode 100644 index 000000000000..92c1643fb7a5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextContent.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageTextContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteObjectValue(InternalDetails, options); + } + + MessageTextContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextContent(document.RootElement, options); + } + + internal static MessageTextContent DeserializeMessageTextContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMessageTextDetails text = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) + { + text = InternalMessageTextDetails.DeserializeInternalMessageTextDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageTextContent(type, serializedAdditionalRawData, text); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageTextContent)} does not support writing '{options.Format}' format."); + } + } + + MessageTextContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageTextContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextContent.cs new file mode 100644 index 000000000000..fcdccb633def --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextContent.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A representation of a textual item of thread message content. + public partial class MessageTextContent : MessageContent + { + /// Initializes a new instance of . + /// The text and associated annotations for this thread message content item. + /// is null. + internal MessageTextContent(InternalMessageTextDetails internalDetails) + { + Argument.AssertNotNull(internalDetails, nameof(internalDetails)); + + Type = "text"; + InternalDetails = internalDetails; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The text and associated annotations for this thread message content item. + internal MessageTextContent(string type, IDictionary serializedAdditionalRawData, InternalMessageTextDetails internalDetails) : base(type, serializedAdditionalRawData) + { + InternalDetails = internalDetails; + } + + /// Initializes a new instance of for deserialization. + internal MessageTextContent() + { + } + + /// The text and associated annotations for this thread message content item. + public InternalMessageTextDetails InternalDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs new file mode 100644 index 000000000000..5cae630300bc --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageTextFileCitationAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextFileCitationAnnotation)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("file_citation"u8); + writer.WriteObjectValue(InternalDetails, options); + if (Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } + } + + MessageTextFileCitationAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextFileCitationAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextFileCitationAnnotation(document.RootElement, options); + } + + internal static MessageTextFileCitationAnnotation DeserializeMessageTextFileCitationAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMessageTextFileCitationDetails fileCitation = default; + int? startIndex = default; + int? endIndex = default; + string type = default; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_citation"u8)) + { + fileCitation = InternalMessageTextFileCitationDetails.DeserializeInternalMessageTextFileCitationDetails(property.Value, options); + continue; + } + if (property.NameEquals("start_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageTextFileCitationAnnotation( + type, + text, + serializedAdditionalRawData, + fileCitation, + startIndex, + endIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageTextFileCitationAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageTextFileCitationAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextFileCitationAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextFileCitationAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageTextFileCitationAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextFileCitationAnnotation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFileCitationAnnotation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFileCitationAnnotation.cs new file mode 100644 index 000000000000..b5e6ca8d7b56 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFileCitationAnnotation.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A citation within the message that points to a specific quote from a specific File associated with the agent or the message. Generated when the agent uses the 'file_search' tool to search files. + public partial class MessageTextFileCitationAnnotation : MessageTextAnnotation + { + /// Initializes a new instance of . + /// The textual content associated with this text annotation item. + /// + /// A citation within the message that points to a specific quote from a specific file. + /// Generated when the agent uses the "file_search" tool to search files. + /// + /// or is null. + internal MessageTextFileCitationAnnotation(string text, InternalMessageTextFileCitationDetails internalDetails) : base(text) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(internalDetails, nameof(internalDetails)); + + Type = "file_citation"; + InternalDetails = internalDetails; + } + + /// Initializes a new instance of . + /// The object type. + /// The textual content associated with this text annotation item. + /// Keeps track of any properties unknown to the library. + /// + /// A citation within the message that points to a specific quote from a specific file. + /// Generated when the agent uses the "file_search" tool to search files. + /// + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + internal MessageTextFileCitationAnnotation(string type, string text, IDictionary serializedAdditionalRawData, InternalMessageTextFileCitationDetails internalDetails, int? startIndex, int? endIndex) : base(type, text, serializedAdditionalRawData) + { + InternalDetails = internalDetails; + StartIndex = startIndex; + EndIndex = endIndex; + } + + /// Initializes a new instance of for deserialization. + internal MessageTextFileCitationAnnotation() + { + } + + /// + /// A citation within the message that points to a specific quote from a specific file. + /// Generated when the agent uses the "file_search" tool to search files. + /// + public InternalMessageTextFileCitationDetails InternalDetails { get; } + /// The first text index associated with this text annotation. + public int? StartIndex { get; } + /// The last text index associated with this text annotation. + public int? EndIndex { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFilePathAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFilePathAnnotation.Serialization.cs new file mode 100644 index 000000000000..1bd1fde98d3f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFilePathAnnotation.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageTextFilePathAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextFilePathAnnotation)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("file_path"u8); + writer.WriteObjectValue(InternalDetails, options); + if (Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } + } + + MessageTextFilePathAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextFilePathAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextFilePathAnnotation(document.RootElement, options); + } + + internal static MessageTextFilePathAnnotation DeserializeMessageTextFilePathAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMessageTextFilePathDetails filePath = default; + int? startIndex = default; + int? endIndex = default; + string type = default; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_path"u8)) + { + filePath = InternalMessageTextFilePathDetails.DeserializeInternalMessageTextFilePathDetails(property.Value, options); + continue; + } + if (property.NameEquals("start_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageTextFilePathAnnotation( + type, + text, + serializedAdditionalRawData, + filePath, + startIndex, + endIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageTextFilePathAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageTextFilePathAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextFilePathAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextFilePathAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageTextFilePathAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextFilePathAnnotation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFilePathAnnotation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFilePathAnnotation.cs new file mode 100644 index 000000000000..c86c9b62851e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextFilePathAnnotation.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A citation within the message that points to a file located at a specific path. + public partial class MessageTextFilePathAnnotation : MessageTextAnnotation + { + /// Initializes a new instance of . + /// The textual content associated with this text annotation item. + /// A URL for the file that's generated when the agent used the code_interpreter tool to generate a file. + /// or is null. + internal MessageTextFilePathAnnotation(string text, InternalMessageTextFilePathDetails internalDetails) : base(text) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(internalDetails, nameof(internalDetails)); + + Type = "file_path"; + InternalDetails = internalDetails; + } + + /// Initializes a new instance of . + /// The object type. + /// The textual content associated with this text annotation item. + /// Keeps track of any properties unknown to the library. + /// A URL for the file that's generated when the agent used the code_interpreter tool to generate a file. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + internal MessageTextFilePathAnnotation(string type, string text, IDictionary serializedAdditionalRawData, InternalMessageTextFilePathDetails internalDetails, int? startIndex, int? endIndex) : base(type, text, serializedAdditionalRawData) + { + InternalDetails = internalDetails; + StartIndex = startIndex; + EndIndex = endIndex; + } + + /// Initializes a new instance of for deserialization. + internal MessageTextFilePathAnnotation() + { + } + + /// A URL for the file that's generated when the agent used the code_interpreter tool to generate a file. + public InternalMessageTextFilePathDetails InternalDetails { get; } + /// The first text index associated with this text annotation. + public int? StartIndex { get; } + /// The last text index associated with this text annotation. + public int? EndIndex { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationAnnotation.Serialization.cs new file mode 100644 index 000000000000..e3ac9d0f87af --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationAnnotation.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageTextUrlCitationAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextUrlCitationAnnotation)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("url_citation"u8); + writer.WriteObjectValue(UrlCitation, options); + if (Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } + } + + MessageTextUrlCitationAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextUrlCitationAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextUrlCitationAnnotation(document.RootElement, options); + } + + internal static MessageTextUrlCitationAnnotation DeserializeMessageTextUrlCitationAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageTextUrlCitationDetails urlCitation = default; + int? startIndex = default; + int? endIndex = default; + string type = default; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url_citation"u8)) + { + urlCitation = MessageTextUrlCitationDetails.DeserializeMessageTextUrlCitationDetails(property.Value, options); + continue; + } + if (property.NameEquals("start_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageTextUrlCitationAnnotation( + type, + text, + serializedAdditionalRawData, + urlCitation, + startIndex, + endIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageTextUrlCitationAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageTextUrlCitationAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextUrlCitationAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextUrlCitationAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageTextUrlCitationAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextUrlCitationAnnotation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationAnnotation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationAnnotation.cs new file mode 100644 index 000000000000..a7180d4fd780 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationAnnotation.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A citation within the message that points to a specific URL associated with the message. Generated when the agent uses tools such as 'bing_grounding' to search the Internet. + public partial class MessageTextUrlCitationAnnotation : MessageTextAnnotation + { + /// Initializes a new instance of . + /// The textual content associated with this text annotation item. + /// The details of the URL citation. + /// or is null. + internal MessageTextUrlCitationAnnotation(string text, MessageTextUrlCitationDetails urlCitation) : base(text) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(urlCitation, nameof(urlCitation)); + + Type = "url_citation"; + UrlCitation = urlCitation; + } + + /// Initializes a new instance of . + /// The object type. + /// The textual content associated with this text annotation item. + /// Keeps track of any properties unknown to the library. + /// The details of the URL citation. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + internal MessageTextUrlCitationAnnotation(string type, string text, IDictionary serializedAdditionalRawData, MessageTextUrlCitationDetails urlCitation, int? startIndex, int? endIndex) : base(type, text, serializedAdditionalRawData) + { + UrlCitation = urlCitation; + StartIndex = startIndex; + EndIndex = endIndex; + } + + /// Initializes a new instance of for deserialization. + internal MessageTextUrlCitationAnnotation() + { + } + + /// The details of the URL citation. + public MessageTextUrlCitationDetails UrlCitation { get; } + /// The first text index associated with this text annotation. + public int? StartIndex { get; } + /// The last text index associated with this text annotation. + public int? EndIndex { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationDetails.Serialization.cs new file mode 100644 index 000000000000..2b460aee3988 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationDetails.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MessageTextUrlCitationDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextUrlCitationDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url); + if (Optional.IsDefined(Title)) + { + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MessageTextUrlCitationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextUrlCitationDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextUrlCitationDetails(document.RootElement, options); + } + + internal static MessageTextUrlCitationDetails DeserializeMessageTextUrlCitationDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string url = default; + string title = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url"u8)) + { + url = property.Value.GetString(); + continue; + } + if (property.NameEquals("title"u8)) + { + title = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageTextUrlCitationDetails(url, title, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageTextUrlCitationDetails)} does not support writing '{options.Format}' format."); + } + } + + MessageTextUrlCitationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextUrlCitationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextUrlCitationDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageTextUrlCitationDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextUrlCitationDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationDetails.cs new file mode 100644 index 000000000000..e2ebb94dbc42 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MessageTextUrlCitationDetails.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A representation of a URL citation, as used in text thread message content. + public partial class MessageTextUrlCitationDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The URL associated with this citation. + /// is null. + internal MessageTextUrlCitationDetails(string url) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + /// Initializes a new instance of . + /// The URL associated with this citation. + /// The title of the URL. + /// Keeps track of any properties unknown to the library. + internal MessageTextUrlCitationDetails(string url, string title, IDictionary serializedAdditionalRawData) + { + Url = url; + Title = title; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageTextUrlCitationDetails() + { + } + + /// The URL associated with this citation. + public string Url { get; } + /// The title of the URL. + public string Title { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Messages.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Messages.cs new file mode 100644 index 000000000000..eeda1eb7462b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Messages.cs @@ -0,0 +1,667 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Agents.Persistent +{ + // Data plane generated sub-client. + /// A collection of message operations under `/threads/{threadId}/messages`. + public partial class Messages + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Messages for mocking. + protected Messages() + { + } + + /// Initializes a new instance of Messages. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Messages(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Creates a new message on a specified thread. + /// Identifier of the thread. + /// + /// The role of the entity that is creating the message. Allowed values include: + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). + /// + /// + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// A list of files attached to the message, and the tools they should be added to. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateMessageAsync(string threadId, MessageRole role, BinaryData content, IEnumerable attachments = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + CreateMessageRequest createMessageRequest = new CreateMessageRequest(role, content, attachments?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateMessageAsync(threadId, createMessageRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ThreadMessage.FromResponse(response), response); + } + + /// Creates a new message on a specified thread. + /// Identifier of the thread. + /// + /// The role of the entity that is creating the message. Allowed values include: + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). + /// + /// + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// A list of files attached to the message, and the tools they should be added to. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response CreateMessage(string threadId, MessageRole role, BinaryData content, IEnumerable attachments = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + CreateMessageRequest createMessageRequest = new CreateMessageRequest(role, content, attachments?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateMessage(threadId, createMessageRequest.ToRequestContent(), context); + return Response.FromValue(ThreadMessage.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new message on a specified thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// The content to send as the body of the request. + /// The request context, 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 CreateMessageAsync(string threadId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Messages.CreateMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateMessageRequest(threadId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new message on a specified thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// The content to send as the body of the request. + /// The request context, 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 Response CreateMessage(string threadId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Messages.CreateMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateMessageRequest(threadId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of messages that exist on a thread. + /// Identifier of the thread. + /// Filter messages by the run ID that generated them. + /// 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 to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalGetMessagesAsync(string threadId, string runId = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalGetMessagesAsync(threadId, runId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfThreadMessage.FromResponse(response), response); + } + + /// Gets a list of messages that exist on a thread. + /// Identifier of the thread. + /// Filter messages by the run ID that generated them. + /// 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 to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response InternalGetMessages(string threadId, string runId = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalGetMessages(threadId, runId, limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfThreadMessage.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of messages that exist on a thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Filter messages by the run ID that generated them. + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual async Task InternalGetMessagesAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("Messages.InternalGetMessages"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetMessagesRequest(threadId, runId, limit, order, after, before, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a list of messages that exist on a thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Filter messages by the run ID that generated them. + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual Response InternalGetMessages(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("Messages.InternalGetMessages"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetMessagesRequest(threadId, runId, limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves an existing message. + /// Identifier of the thread. + /// Identifier of the message. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetMessageAsync(string threadId, string messageId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetMessageAsync(threadId, messageId, context).ConfigureAwait(false); + return Response.FromValue(ThreadMessage.FromResponse(response), response); + } + + /// Retrieves an existing message. + /// Identifier of the thread. + /// Identifier of the message. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetMessage(string threadId, string messageId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetMessage(threadId, messageId, context); + return Response.FromValue(ThreadMessage.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves an existing message. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the message. + /// The request context, 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 GetMessageAsync(string threadId, string messageId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + using var scope = ClientDiagnostics.CreateScope("Messages.GetMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves an existing message. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the message. + /// The request context, 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 Response GetMessage(string threadId, string messageId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + using var scope = ClientDiagnostics.CreateScope("Messages.GetMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Modifies an existing message on an existing thread. + /// Identifier of the thread. + /// Identifier of the message. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> UpdateMessageAsync(string threadId, string messageId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UpdateMessageAsync(threadId, messageId, updateMessageRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ThreadMessage.FromResponse(response), response); + } + + /// Modifies an existing message on an existing thread. + /// Identifier of the thread. + /// Identifier of the message. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response UpdateMessage(string threadId, string messageId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UpdateMessage(threadId, messageId, updateMessageRequest.ToRequestContent(), context); + return Response.FromValue(ThreadMessage.FromResponse(response), response); + } + + /// + /// [Protocol Method] Modifies an existing message on an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the message. + /// The content to send as the body of the request. + /// The request context, 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 UpdateMessageAsync(string threadId, string messageId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Messages.UpdateMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Modifies an existing message on an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the message. + /// The content to send as the body of the request. + /// The request context, 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 Response UpdateMessage(string threadId, string messageId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Messages.UpdateMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCreateMessageRequest(string threadId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalGetMessagesRequest(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (runId != null) + { + uri.AppendQuery("run_id", runId, true); + } + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMessageRequest(string threadId, string messageId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages/", false); + uri.AppendPath(messageId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUpdateMessageRequest(string threadId, string messageId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages/", false); + uri.AppendPath(messageId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MicrosoftFabricToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MicrosoftFabricToolDefinition.Serialization.cs new file mode 100644 index 000000000000..f0a1fb915166 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MicrosoftFabricToolDefinition.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class MicrosoftFabricToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MicrosoftFabricToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("fabric_dataagent"u8); + writer.WriteObjectValue(FabricDataagent, options); + } + + MicrosoftFabricToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MicrosoftFabricToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMicrosoftFabricToolDefinition(document.RootElement, options); + } + + internal static MicrosoftFabricToolDefinition DeserializeMicrosoftFabricToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolConnectionList fabricDataagent = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fabric_dataagent"u8)) + { + fabricDataagent = ToolConnectionList.DeserializeToolConnectionList(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MicrosoftFabricToolDefinition(type, serializedAdditionalRawData, fabricDataagent); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MicrosoftFabricToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + MicrosoftFabricToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMicrosoftFabricToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MicrosoftFabricToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MicrosoftFabricToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMicrosoftFabricToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MicrosoftFabricToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MicrosoftFabricToolDefinition.cs new file mode 100644 index 000000000000..2cddbbe72198 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/MicrosoftFabricToolDefinition.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for a Microsoft Fabric tool as used to configure an agent. + public partial class MicrosoftFabricToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + /// The list of connections used by the Microsoft Fabric tool. + /// is null. + public MicrosoftFabricToolDefinition(ToolConnectionList fabricDataagent) + { + Argument.AssertNotNull(fabricDataagent, nameof(fabricDataagent)); + + Type = "fabric_dataagent"; + FabricDataagent = fabricDataagent; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The list of connections used by the Microsoft Fabric tool. + internal MicrosoftFabricToolDefinition(string type, IDictionary serializedAdditionalRawData, ToolConnectionList fabricDataagent) : base(type, serializedAdditionalRawData) + { + FabricDataagent = fabricDataagent; + } + + /// Initializes a new instance of for deserialization. + internal MicrosoftFabricToolDefinition() + { + } + + /// The list of connections used by the Microsoft Fabric tool. + public ToolConnectionList FabricDataagent { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ModifyVectorStoreRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ModifyVectorStoreRequest.Serialization.cs new file mode 100644 index 000000000000..49b013511382 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ModifyVectorStoreRequest.Serialization.cs @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class ModifyVectorStoreRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModifyVectorStoreRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Name)) + { + if (Name != null) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + else + { + writer.WriteNull("name"); + } + } + if (Optional.IsDefined(ExpiresAfter)) + { + if (ExpiresAfter != null) + { + writer.WritePropertyName("expires_after"u8); + writer.WriteObjectValue(ExpiresAfter, options); + } + else + { + writer.WriteNull("expires_after"); + } + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ModifyVectorStoreRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModifyVectorStoreRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModifyVectorStoreRequest(document.RootElement, options); + } + + internal static ModifyVectorStoreRequest DeserializeModifyVectorStoreRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + VectorStoreExpirationPolicy expiresAfter = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + name = null; + continue; + } + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("expires_after"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + expiresAfter = null; + continue; + } + expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ModifyVectorStoreRequest(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ModifyVectorStoreRequest)} does not support writing '{options.Format}' format."); + } + } + + ModifyVectorStoreRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeModifyVectorStoreRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModifyVectorStoreRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ModifyVectorStoreRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeModifyVectorStoreRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ModifyVectorStoreRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ModifyVectorStoreRequest.cs new file mode 100644 index 000000000000..99b7e4d43739 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ModifyVectorStoreRequest.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The ModifyVectorStoreRequest. + internal partial class ModifyVectorStoreRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ModifyVectorStoreRequest() + { + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The name of the vector store. + /// Details on when this vector store expires. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal ModifyVectorStoreRequest(string name, VectorStoreExpirationPolicy expiresAfter, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Name = name; + ExpiresAfter = expiresAfter; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name of the vector store. + public string Name { get; } + /// Details on when this vector store expires. + public VectorStoreExpirationPolicy ExpiresAfter { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFile.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFile.Serialization.cs new file mode 100644 index 000000000000..b489460f9ce6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFile.Serialization.cs @@ -0,0 +1,217 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class OpenAIFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIFile)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("bytes"u8); + writer.WriteNumberValue(Size); + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("purpose"u8); + writer.WriteStringValue(Purpose.ToString()); + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (Optional.IsDefined(StatusDetails)) + { + writer.WritePropertyName("status_details"u8); + writer.WriteStringValue(StatusDetails); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenAIFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIFile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIFile(document.RootElement, options); + } + + internal static OpenAIFile DeserializeOpenAIFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIFileObject @object = default; + string id = default; + int bytes = default; + string filename = default; + DateTimeOffset createdAt = default; + OpenAIFilePurpose purpose = default; + FileState? status = default; + string statusDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIFileObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("bytes"u8)) + { + bytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("filename"u8)) + { + filename = property.Value.GetString(); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("purpose"u8)) + { + purpose = new OpenAIFilePurpose(property.Value.GetString()); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new FileState(property.Value.GetString()); + continue; + } + if (property.NameEquals("status_details"u8)) + { + statusDetails = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIFile( + @object, + id, + bytes, + filename, + createdAt, + purpose, + status, + statusDetails, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIFile)} does not support writing '{options.Format}' format."); + } + } + + OpenAIFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIFile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenAIFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIFile(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFile.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFile.cs new file mode 100644 index 000000000000..a7246aa9c0fb --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFile.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents an agent that can call the model and use tools. + public partial class OpenAIFile + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The size of the file, in bytes. + /// The name of the file. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The intended purpose of a file. + /// or is null. + internal OpenAIFile(string id, int size, string filename, DateTimeOffset createdAt, OpenAIFilePurpose purpose) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(filename, nameof(filename)); + + Id = id; + Size = size; + Filename = filename; + CreatedAt = createdAt; + Purpose = purpose; + } + + /// Initializes a new instance of . + /// The object type, which is always 'file'. + /// The identifier, which can be referenced in API endpoints. + /// The size of the file, in bytes. + /// The name of the file. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The intended purpose of a file. + /// The state of the file. This field is available in Azure OpenAI only. + /// The error message with details in case processing of this file failed. This field is available in Azure OpenAI only. + /// Keeps track of any properties unknown to the library. + internal OpenAIFile(OpenAIFileObject @object, string id, int size, string filename, DateTimeOffset createdAt, OpenAIFilePurpose purpose, FileState? status, string statusDetails, IDictionary serializedAdditionalRawData) + { + Object = @object; + Id = id; + Size = size; + Filename = filename; + CreatedAt = createdAt; + Purpose = purpose; + Status = status; + StatusDetails = statusDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenAIFile() + { + } + + /// The object type, which is always 'file'. + public OpenAIFileObject Object { get; } = OpenAIFileObject.File; + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The size of the file, in bytes. + public int Size { get; } + /// The name of the file. + public string Filename { get; } + /// The Unix timestamp, in seconds, representing when this object was created. + public DateTimeOffset CreatedAt { get; } + /// The intended purpose of a file. + public OpenAIFilePurpose Purpose { get; } + /// The state of the file. This field is available in Azure OpenAI only. + public FileState? Status { get; } + /// The error message with details in case processing of this file failed. This field is available in Azure OpenAI only. + public string StatusDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFileObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFileObject.cs new file mode 100644 index 000000000000..818311b7686b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFileObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The OpenAIFile_object. + public readonly partial struct OpenAIFileObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIFileObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FileValue = "file"; + + /// file. + public static OpenAIFileObject File { get; } = new OpenAIFileObject(FileValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIFileObject left, OpenAIFileObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIFileObject left, OpenAIFileObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenAIFileObject(string value) => new OpenAIFileObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIFileObject other && Equals(other); + /// + public bool Equals(OpenAIFileObject 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.Agents.Persistent/src/Generated/OpenAIFilePurpose.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFilePurpose.cs new file mode 100644 index 000000000000..5b750efe746a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIFilePurpose.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The possible values denoting the intended usage of a file. + public readonly partial struct OpenAIFilePurpose : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIFilePurpose(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FineTuneValue = "fine-tune"; + private const string FineTuneResultsValue = "fine-tune-results"; + private const string AgentsValue = "assistants"; + private const string AgentsOutputValue = "assistants_output"; + private const string BatchValue = "batch"; + private const string BatchOutputValue = "batch_output"; + private const string VisionValue = "vision"; + + /// Indicates a file is used for fine tuning input. + public static OpenAIFilePurpose FineTune { get; } = new OpenAIFilePurpose(FineTuneValue); + /// Indicates a file is used for fine tuning results. + public static OpenAIFilePurpose FineTuneResults { get; } = new OpenAIFilePurpose(FineTuneResultsValue); + /// Indicates a file is used as input to agents. + public static OpenAIFilePurpose Agents { get; } = new OpenAIFilePurpose(AgentsValue); + /// Indicates a file is used as output by agents. + public static OpenAIFilePurpose AgentsOutput { get; } = new OpenAIFilePurpose(AgentsOutputValue); + /// Indicates a file is used as input to . + public static OpenAIFilePurpose Batch { get; } = new OpenAIFilePurpose(BatchValue); + /// Indicates a file is used as output by a vector store batch operation. + public static OpenAIFilePurpose BatchOutput { get; } = new OpenAIFilePurpose(BatchOutputValue); + /// Indicates a file is used as input to a vision operation. + public static OpenAIFilePurpose Vision { get; } = new OpenAIFilePurpose(VisionValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIFilePurpose left, OpenAIFilePurpose right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIFilePurpose left, OpenAIFilePurpose right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenAIFilePurpose(string value) => new OpenAIFilePurpose(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIFilePurpose other && Equals(other); + /// + public bool Equals(OpenAIFilePurpose 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.Agents.Persistent/src/Generated/OpenAIPageableListOfAgent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgent.Serialization.cs new file mode 100644 index 000000000000..c8d60f110437 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgent.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class OpenAIPageableListOfAgent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfAgent)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenAIPageableListOfAgent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfAgent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfAgent(document.RootElement, options); + } + + internal static OpenAIPageableListOfAgent DeserializeOpenAIPageableListOfAgent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfAgentObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfAgentObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(PersistentAgent.DeserializePersistentAgent(item, options)); + } + data = array; + continue; + } + if (property.NameEquals("first_id"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIPageableListOfAgent( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfAgent)} does not support writing '{options.Format}' format."); + } + } + + OpenAIPageableListOfAgent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfAgent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfAgent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenAIPageableListOfAgent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfAgent(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgent.cs new file mode 100644 index 000000000000..58f0a164bef6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgent.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The response data for a requested list of items. + internal partial class OpenAIPageableListOfAgent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// , or is null. + internal OpenAIPageableListOfAgent(IEnumerable data, string firstId, string lastId, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// Keeps track of any properties unknown to the library. + internal OpenAIPageableListOfAgent(OpenAIPageableListOfAgentObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenAIPageableListOfAgent() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfAgentObject Object { get; } = OpenAIPageableListOfAgentObject.List; + + /// The requested list of items. + public IReadOnlyList Data { get; } + /// The first ID represented in this list. + public string FirstId { get; } + /// The last ID represented in this list. + public string LastId { get; } + /// A value indicating whether there are additional values available not captured in this list. + public bool HasMore { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentObject.cs new file mode 100644 index 000000000000..fd1960f4e07f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The OpenAIPageableListOfAgent_object. + internal readonly partial struct OpenAIPageableListOfAgentObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfAgentObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfAgentObject List { get; } = new OpenAIPageableListOfAgentObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfAgentObject left, OpenAIPageableListOfAgentObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfAgentObject left, OpenAIPageableListOfAgentObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenAIPageableListOfAgentObject(string value) => new OpenAIPageableListOfAgentObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfAgentObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfAgentObject 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.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThread.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThread.Serialization.cs new file mode 100644 index 000000000000..7444ddae2842 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThread.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class OpenAIPageableListOfAgentThread : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfAgentThread)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenAIPageableListOfAgentThread IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfAgentThread)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfAgentThread(document.RootElement, options); + } + + internal static OpenAIPageableListOfAgentThread DeserializeOpenAIPageableListOfAgentThread(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfAgentThreadObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfAgentThreadObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(PersistentAgentThread.DeserializePersistentAgentThread(item, options)); + } + data = array; + continue; + } + if (property.NameEquals("first_id"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIPageableListOfAgentThread( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfAgentThread)} does not support writing '{options.Format}' format."); + } + } + + OpenAIPageableListOfAgentThread IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfAgentThread(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfAgentThread)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenAIPageableListOfAgentThread FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfAgentThread(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThread.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThread.cs new file mode 100644 index 000000000000..e0563319121e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThread.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The response data for a requested list of items. + internal partial class OpenAIPageableListOfAgentThread + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// , or is null. + internal OpenAIPageableListOfAgentThread(IEnumerable data, string firstId, string lastId, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// Keeps track of any properties unknown to the library. + internal OpenAIPageableListOfAgentThread(OpenAIPageableListOfAgentThreadObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenAIPageableListOfAgentThread() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfAgentThreadObject Object { get; } = OpenAIPageableListOfAgentThreadObject.List; + + /// The requested list of items. + public IReadOnlyList Data { get; } + /// The first ID represented in this list. + public string FirstId { get; } + /// The last ID represented in this list. + public string LastId { get; } + /// A value indicating whether there are additional values available not captured in this list. + public bool HasMore { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThreadObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThreadObject.cs new file mode 100644 index 000000000000..4172355ef27a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfAgentThreadObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The OpenAIPageableListOfAgentThread_object. + internal readonly partial struct OpenAIPageableListOfAgentThreadObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfAgentThreadObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfAgentThreadObject List { get; } = new OpenAIPageableListOfAgentThreadObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfAgentThreadObject left, OpenAIPageableListOfAgentThreadObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfAgentThreadObject left, OpenAIPageableListOfAgentThreadObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenAIPageableListOfAgentThreadObject(string value) => new OpenAIPageableListOfAgentThreadObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfAgentThreadObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfAgentThreadObject 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.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStep.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStep.Serialization.cs new file mode 100644 index 000000000000..3a5af43c6b1d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStep.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class OpenAIPageableListOfRunStep : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfRunStep)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenAIPageableListOfRunStep IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfRunStep)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfRunStep(document.RootElement, options); + } + + internal static OpenAIPageableListOfRunStep DeserializeOpenAIPageableListOfRunStep(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfRunStepObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfRunStepObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RunStep.DeserializeRunStep(item, options)); + } + data = array; + continue; + } + if (property.NameEquals("first_id"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIPageableListOfRunStep( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfRunStep)} does not support writing '{options.Format}' format."); + } + } + + OpenAIPageableListOfRunStep IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfRunStep(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfRunStep)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenAIPageableListOfRunStep FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfRunStep(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStep.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStep.cs new file mode 100644 index 000000000000..e36b6d99b42f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStep.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The response data for a requested list of items. + internal partial class OpenAIPageableListOfRunStep + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// , or is null. + internal OpenAIPageableListOfRunStep(IEnumerable data, string firstId, string lastId, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// Keeps track of any properties unknown to the library. + internal OpenAIPageableListOfRunStep(OpenAIPageableListOfRunStepObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenAIPageableListOfRunStep() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfRunStepObject Object { get; } = OpenAIPageableListOfRunStepObject.List; + + /// The requested list of items. + public IReadOnlyList Data { get; } + /// The first ID represented in this list. + public string FirstId { get; } + /// The last ID represented in this list. + public string LastId { get; } + /// A value indicating whether there are additional values available not captured in this list. + public bool HasMore { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStepObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStepObject.cs new file mode 100644 index 000000000000..66d3dabd0844 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfRunStepObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The OpenAIPageableListOfRunStep_object. + internal readonly partial struct OpenAIPageableListOfRunStepObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfRunStepObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfRunStepObject List { get; } = new OpenAIPageableListOfRunStepObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfRunStepObject left, OpenAIPageableListOfRunStepObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfRunStepObject left, OpenAIPageableListOfRunStepObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenAIPageableListOfRunStepObject(string value) => new OpenAIPageableListOfRunStepObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfRunStepObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfRunStepObject 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.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessage.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessage.Serialization.cs new file mode 100644 index 000000000000..5bce11f1bab3 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessage.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class OpenAIPageableListOfThreadMessage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadMessage)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenAIPageableListOfThreadMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfThreadMessage(document.RootElement, options); + } + + internal static OpenAIPageableListOfThreadMessage DeserializeOpenAIPageableListOfThreadMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfThreadMessageObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfThreadMessageObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ThreadMessage.DeserializeThreadMessage(item, options)); + } + data = array; + continue; + } + if (property.NameEquals("first_id"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIPageableListOfThreadMessage( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadMessage)} does not support writing '{options.Format}' format."); + } + } + + OpenAIPageableListOfThreadMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfThreadMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadMessage)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenAIPageableListOfThreadMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfThreadMessage(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessage.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessage.cs new file mode 100644 index 000000000000..9112e946fccd --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessage.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The response data for a requested list of items. + internal partial class OpenAIPageableListOfThreadMessage + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// , or is null. + internal OpenAIPageableListOfThreadMessage(IEnumerable data, string firstId, string lastId, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// Keeps track of any properties unknown to the library. + internal OpenAIPageableListOfThreadMessage(OpenAIPageableListOfThreadMessageObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenAIPageableListOfThreadMessage() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfThreadMessageObject Object { get; } = OpenAIPageableListOfThreadMessageObject.List; + + /// The requested list of items. + public IReadOnlyList Data { get; } + /// The first ID represented in this list. + public string FirstId { get; } + /// The last ID represented in this list. + public string LastId { get; } + /// A value indicating whether there are additional values available not captured in this list. + public bool HasMore { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessageObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessageObject.cs new file mode 100644 index 000000000000..96e92a60b4d6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadMessageObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The OpenAIPageableListOfThreadMessage_object. + internal readonly partial struct OpenAIPageableListOfThreadMessageObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfThreadMessageObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfThreadMessageObject List { get; } = new OpenAIPageableListOfThreadMessageObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfThreadMessageObject left, OpenAIPageableListOfThreadMessageObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfThreadMessageObject left, OpenAIPageableListOfThreadMessageObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenAIPageableListOfThreadMessageObject(string value) => new OpenAIPageableListOfThreadMessageObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfThreadMessageObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfThreadMessageObject 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.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRun.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRun.Serialization.cs new file mode 100644 index 000000000000..390e2dd38803 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRun.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class OpenAIPageableListOfThreadRun : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadRun)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenAIPageableListOfThreadRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadRun)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfThreadRun(document.RootElement, options); + } + + internal static OpenAIPageableListOfThreadRun DeserializeOpenAIPageableListOfThreadRun(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfThreadRunObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfThreadRunObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ThreadRun.DeserializeThreadRun(item, options)); + } + data = array; + continue; + } + if (property.NameEquals("first_id"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIPageableListOfThreadRun( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadRun)} does not support writing '{options.Format}' format."); + } + } + + OpenAIPageableListOfThreadRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfThreadRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadRun)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenAIPageableListOfThreadRun FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfThreadRun(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRun.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRun.cs new file mode 100644 index 000000000000..af1bcb5a9894 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRun.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The response data for a requested list of items. + internal partial class OpenAIPageableListOfThreadRun + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// , or is null. + internal OpenAIPageableListOfThreadRun(IEnumerable data, string firstId, string lastId, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// Keeps track of any properties unknown to the library. + internal OpenAIPageableListOfThreadRun(OpenAIPageableListOfThreadRunObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenAIPageableListOfThreadRun() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfThreadRunObject Object { get; } = OpenAIPageableListOfThreadRunObject.List; + + /// The requested list of items. + public IReadOnlyList Data { get; } + /// The first ID represented in this list. + public string FirstId { get; } + /// The last ID represented in this list. + public string LastId { get; } + /// A value indicating whether there are additional values available not captured in this list. + public bool HasMore { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRunObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRunObject.cs new file mode 100644 index 000000000000..5051dc51ae0e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfThreadRunObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The OpenAIPageableListOfThreadRun_object. + internal readonly partial struct OpenAIPageableListOfThreadRunObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfThreadRunObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfThreadRunObject List { get; } = new OpenAIPageableListOfThreadRunObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfThreadRunObject left, OpenAIPageableListOfThreadRunObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfThreadRunObject left, OpenAIPageableListOfThreadRunObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenAIPageableListOfThreadRunObject(string value) => new OpenAIPageableListOfThreadRunObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfThreadRunObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfThreadRunObject 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.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStore.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStore.Serialization.cs new file mode 100644 index 000000000000..8ad1ff22fff7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStore.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class OpenAIPageableListOfVectorStore : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStore)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenAIPageableListOfVectorStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStore)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfVectorStore(document.RootElement, options); + } + + internal static OpenAIPageableListOfVectorStore DeserializeOpenAIPageableListOfVectorStore(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfVectorStoreObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfVectorStoreObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VectorStore.DeserializeVectorStore(item, options)); + } + data = array; + continue; + } + if (property.NameEquals("first_id"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIPageableListOfVectorStore( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStore)} does not support writing '{options.Format}' format."); + } + } + + OpenAIPageableListOfVectorStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfVectorStore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStore)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenAIPageableListOfVectorStore FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfVectorStore(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStore.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStore.cs new file mode 100644 index 000000000000..e40d110ba459 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStore.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The response data for a requested list of items. + public partial class OpenAIPageableListOfVectorStore + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// , or is null. + internal OpenAIPageableListOfVectorStore(IEnumerable data, string firstId, string lastId, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// Keeps track of any properties unknown to the library. + internal OpenAIPageableListOfVectorStore(OpenAIPageableListOfVectorStoreObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenAIPageableListOfVectorStore() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfVectorStoreObject Object { get; } = OpenAIPageableListOfVectorStoreObject.List; + + /// The requested list of items. + public IReadOnlyList Data { get; } + /// The first ID represented in this list. + public string FirstId { get; } + /// The last ID represented in this list. + public string LastId { get; } + /// A value indicating whether there are additional values available not captured in this list. + public bool HasMore { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFile.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFile.Serialization.cs new file mode 100644 index 000000000000..6be338c5ab21 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFile.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class OpenAIPageableListOfVectorStoreFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStoreFile)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenAIPageableListOfVectorStoreFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStoreFile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfVectorStoreFile(document.RootElement, options); + } + + internal static OpenAIPageableListOfVectorStoreFile DeserializeOpenAIPageableListOfVectorStoreFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfVectorStoreFileObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfVectorStoreFileObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VectorStoreFile.DeserializeVectorStoreFile(item, options)); + } + data = array; + continue; + } + if (property.NameEquals("first_id"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIPageableListOfVectorStoreFile( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStoreFile)} does not support writing '{options.Format}' format."); + } + } + + OpenAIPageableListOfVectorStoreFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfVectorStoreFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStoreFile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenAIPageableListOfVectorStoreFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenAIPageableListOfVectorStoreFile(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFile.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFile.cs new file mode 100644 index 000000000000..b3a59d689143 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFile.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The response data for a requested list of items. + public partial class OpenAIPageableListOfVectorStoreFile + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// , or is null. + internal OpenAIPageableListOfVectorStoreFile(IEnumerable data, string firstId, string lastId, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// Keeps track of any properties unknown to the library. + internal OpenAIPageableListOfVectorStoreFile(OpenAIPageableListOfVectorStoreFileObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenAIPageableListOfVectorStoreFile() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfVectorStoreFileObject Object { get; } = OpenAIPageableListOfVectorStoreFileObject.List; + + /// The requested list of items. + public IReadOnlyList Data { get; } + /// The first ID represented in this list. + public string FirstId { get; } + /// The last ID represented in this list. + public string LastId { get; } + /// A value indicating whether there are additional values available not captured in this list. + public bool HasMore { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFileObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFileObject.cs new file mode 100644 index 000000000000..ac22b3be3d35 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreFileObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The OpenAIPageableListOfVectorStoreFile_object. + public readonly partial struct OpenAIPageableListOfVectorStoreFileObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfVectorStoreFileObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfVectorStoreFileObject List { get; } = new OpenAIPageableListOfVectorStoreFileObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfVectorStoreFileObject left, OpenAIPageableListOfVectorStoreFileObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfVectorStoreFileObject left, OpenAIPageableListOfVectorStoreFileObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenAIPageableListOfVectorStoreFileObject(string value) => new OpenAIPageableListOfVectorStoreFileObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfVectorStoreFileObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfVectorStoreFileObject 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.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreObject.cs new file mode 100644 index 000000000000..87c504fa1b77 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenAIPageableListOfVectorStoreObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The OpenAIPageableListOfVectorStore_object. + public readonly partial struct OpenAIPageableListOfVectorStoreObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfVectorStoreObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfVectorStoreObject List { get; } = new OpenAIPageableListOfVectorStoreObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfVectorStoreObject left, OpenAIPageableListOfVectorStoreObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfVectorStoreObject left, OpenAIPageableListOfVectorStoreObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenAIPageableListOfVectorStoreObject(string value) => new OpenAIPageableListOfVectorStoreObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfVectorStoreObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfVectorStoreObject 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.Agents.Persistent/src/Generated/OpenApiAnonymousAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAnonymousAuthDetails.Serialization.cs new file mode 100644 index 000000000000..031a5089fc75 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAnonymousAuthDetails.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class OpenApiAnonymousAuthDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var 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); + } + + OpenApiAnonymousAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAnonymousAuthDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiAnonymousAuthDetails(document.RootElement, options); + } + + internal static OpenApiAnonymousAuthDetails DeserializeOpenApiAnonymousAuthDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiAuthType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new OpenApiAuthType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenApiAnonymousAuthDetails(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenApiAnonymousAuthDetails)} does not support writing '{options.Format}' format."); + } + } + + OpenApiAnonymousAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiAnonymousAuthDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiAnonymousAuthDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new OpenApiAnonymousAuthDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiAnonymousAuthDetails(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAnonymousAuthDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAnonymousAuthDetails.cs new file mode 100644 index 000000000000..638b261e9f72 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAnonymousAuthDetails.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Security details for OpenApi anonymous authentication. + public partial class OpenApiAnonymousAuthDetails : OpenApiAuthDetails + { + /// Initializes a new instance of . + public OpenApiAnonymousAuthDetails() + { + Type = OpenApiAuthType.Anonymous; + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/connection/managed_identity. + /// Keeps track of any properties unknown to the library. + internal OpenApiAnonymousAuthDetails(OpenApiAuthType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthDetails.Serialization.cs new file mode 100644 index 000000000000..01cf03a32a75 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthDetails.Serialization.cs @@ -0,0 +1,135 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownOpenApiAuthDetails))] + public partial class OpenApiAuthDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenApiAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiAuthDetails(document.RootElement, options); + } + + internal static OpenApiAuthDetails DeserializeOpenApiAuthDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "anonymous": return OpenApiAnonymousAuthDetails.DeserializeOpenApiAnonymousAuthDetails(element, options); + case "connection": return OpenApiConnectionAuthDetails.DeserializeOpenApiConnectionAuthDetails(element, options); + case "managed_identity": return OpenApiManagedAuthDetails.DeserializeOpenApiManagedAuthDetails(element, options); + } + } + return UnknownOpenApiAuthDetails.DeserializeUnknownOpenApiAuthDetails(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support writing '{options.Format}' format."); + } + } + + OpenApiAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiAuthDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenApiAuthDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiAuthDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthDetails.cs new file mode 100644 index 000000000000..f48a94372544 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthDetails.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// authentication details for OpenApiFunctionDefinition + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class OpenApiAuthDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected OpenApiAuthDetails() + { + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/connection/managed_identity. + /// Keeps track of any properties unknown to the library. + internal OpenApiAuthDetails(OpenApiAuthType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The type of authentication, must be anonymous/connection/managed_identity. + internal OpenApiAuthType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthType.cs new file mode 100644 index 000000000000..67f04bd32fc2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiAuthType.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// Authentication type for OpenApi endpoint. Allowed types are: + /// - Anonymous (no authentication required) + /// - Connection (requires 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; + + /// Initializes a new instance of . + /// is null. + public OpenApiAuthType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AnonymousValue = "anonymous"; + private const string ConnectionValue = "connection"; + private const string ManagedIdentityValue = "managed_identity"; + + /// anonymous. + public static OpenApiAuthType Anonymous { get; } = new OpenApiAuthType(AnonymousValue); + /// connection. + public static OpenApiAuthType Connection { get; } = new OpenApiAuthType(ConnectionValue); + /// managed_identity. + public static OpenApiAuthType ManagedIdentity { get; } = new OpenApiAuthType(ManagedIdentityValue); + /// Determines if two values are the same. + public static bool operator ==(OpenApiAuthType left, OpenApiAuthType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenApiAuthType left, OpenApiAuthType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OpenApiAuthType(string value) => 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.Agents.Persistent/src/Generated/OpenApiConnectionAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionAuthDetails.Serialization.cs new file mode 100644 index 000000000000..3bd2a2012774 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionAuthDetails.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class OpenApiConnectionAuthDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiConnectionAuthDetails)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("security_scheme"u8); + writer.WriteObjectValue(SecurityScheme, options); + } + + OpenApiConnectionAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiConnectionAuthDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiConnectionAuthDetails(document.RootElement, options); + } + + internal static OpenApiConnectionAuthDetails DeserializeOpenApiConnectionAuthDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiConnectionSecurityScheme securityScheme = default; + OpenApiAuthType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("security_scheme"u8)) + { + securityScheme = OpenApiConnectionSecurityScheme.DeserializeOpenApiConnectionSecurityScheme(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new OpenApiAuthType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenApiConnectionAuthDetails(type, serializedAdditionalRawData, securityScheme); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenApiConnectionAuthDetails)} does not support writing '{options.Format}' format."); + } + } + + OpenApiConnectionAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiConnectionAuthDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiConnectionAuthDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new OpenApiConnectionAuthDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiConnectionAuthDetails(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionAuthDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionAuthDetails.cs new file mode 100644 index 000000000000..4b0f515d32e1 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionAuthDetails.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Security details for OpenApi connection authentication. + public partial class OpenApiConnectionAuthDetails : OpenApiAuthDetails + { + /// Initializes a new instance of . + /// Connection auth security details. + /// is null. + public OpenApiConnectionAuthDetails(OpenApiConnectionSecurityScheme securityScheme) + { + Argument.AssertNotNull(securityScheme, nameof(securityScheme)); + + Type = OpenApiAuthType.Connection; + SecurityScheme = securityScheme; + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/connection/managed_identity. + /// Keeps track of any properties unknown to the library. + /// Connection auth security details. + internal OpenApiConnectionAuthDetails(OpenApiAuthType type, IDictionary serializedAdditionalRawData, OpenApiConnectionSecurityScheme securityScheme) : base(type, serializedAdditionalRawData) + { + SecurityScheme = securityScheme; + } + + /// Initializes a new instance of for deserialization. + internal OpenApiConnectionAuthDetails() + { + } + + /// Connection auth security details. + public OpenApiConnectionSecurityScheme SecurityScheme { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionSecurityScheme.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionSecurityScheme.Serialization.cs new file mode 100644 index 000000000000..1b203cea54b9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionSecurityScheme.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class OpenApiConnectionSecurityScheme : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiConnectionSecurityScheme)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("connection_id"u8); + writer.WriteStringValue(ConnectionId); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenApiConnectionSecurityScheme IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiConnectionSecurityScheme)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiConnectionSecurityScheme(document.RootElement, options); + } + + internal static OpenApiConnectionSecurityScheme DeserializeOpenApiConnectionSecurityScheme(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string connectionId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connection_id"u8)) + { + connectionId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenApiConnectionSecurityScheme(connectionId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenApiConnectionSecurityScheme)} does not support writing '{options.Format}' format."); + } + } + + OpenApiConnectionSecurityScheme IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiConnectionSecurityScheme(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiConnectionSecurityScheme)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenApiConnectionSecurityScheme FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiConnectionSecurityScheme(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionSecurityScheme.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionSecurityScheme.cs new file mode 100644 index 000000000000..37b97bf8d332 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiConnectionSecurityScheme.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Security scheme for OpenApi managed_identity authentication. + public partial class OpenApiConnectionSecurityScheme + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Connection id for Connection auth type. + /// is null. + public OpenApiConnectionSecurityScheme(string connectionId) + { + Argument.AssertNotNull(connectionId, nameof(connectionId)); + + ConnectionId = connectionId; + } + + /// Initializes a new instance of . + /// Connection id for Connection auth type. + /// Keeps track of any properties unknown to the library. + internal OpenApiConnectionSecurityScheme(string connectionId, IDictionary serializedAdditionalRawData) + { + ConnectionId = connectionId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenApiConnectionSecurityScheme() + { + } + + /// Connection id for Connection auth type. + public string ConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiFunctionDefinition.Serialization.cs new file mode 100644 index 000000000000..8a7c53f04c6d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiFunctionDefinition.Serialization.cs @@ -0,0 +1,207 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class OpenApiFunctionDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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 (var item in DefaultParams) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenApiFunctionDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiFunctionDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiFunctionDefinition(document.RootElement, options); + } + + internal static OpenApiFunctionDefinition DeserializeOpenApiFunctionDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData spec = default; + OpenApiAuthDetails auth = default; + IList defaultParams = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("spec"u8)) + { + spec = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("auth"u8)) + { + auth = OpenApiAuthDetails.DeserializeOpenApiAuthDetails(property.Value, options); + continue; + } + if (property.NameEquals("default_params"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + defaultParams = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenApiFunctionDefinition( + name, + description, + spec, + auth, + defaultParams ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenApiFunctionDefinition)} does not support writing '{options.Format}' format."); + } + } + + OpenApiFunctionDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiFunctionDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiFunctionDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenApiFunctionDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiFunctionDefinition(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiFunctionDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiFunctionDefinition.cs new file mode 100644 index 000000000000..e537de02f25c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiFunctionDefinition.cs @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for an openapi function. + public partial class OpenApiFunctionDefinition + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// 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 + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// , 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(); + } + + /// 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 + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// List of OpenAPI spec parameters that will use user-provided defaults. + /// Keeps track of any properties unknown to the library. + internal OpenApiFunctionDefinition(string name, string description, BinaryData spec, OpenApiAuthDetails auth, IList defaultParams, IDictionary serializedAdditionalRawData) + { + Name = name; + Description = description; + Spec = spec; + Auth = auth; + DefaultParams = defaultParams; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenApiFunctionDefinition() + { + } + + /// 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 + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public OpenApiAuthDetails Auth { get; set; } + /// List of OpenAPI spec parameters that will use user-provided defaults. + public IList DefaultParams { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedAuthDetails.Serialization.cs new file mode 100644 index 000000000000..ecb288636722 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedAuthDetails.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class OpenApiManagedAuthDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var 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); + } + + OpenApiManagedAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiManagedAuthDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiManagedAuthDetails(document.RootElement, options); + } + + internal static OpenApiManagedAuthDetails DeserializeOpenApiManagedAuthDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiManagedSecurityScheme securityScheme = default; + OpenApiAuthType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("security_scheme"u8)) + { + securityScheme = OpenApiManagedSecurityScheme.DeserializeOpenApiManagedSecurityScheme(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new OpenApiAuthType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenApiManagedAuthDetails(type, serializedAdditionalRawData, securityScheme); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenApiManagedAuthDetails)} does not support writing '{options.Format}' format."); + } + } + + OpenApiManagedAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiManagedAuthDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiManagedAuthDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new OpenApiManagedAuthDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiManagedAuthDetails(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedAuthDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedAuthDetails.cs new file mode 100644 index 000000000000..b21c71b2e6d9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedAuthDetails.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Security details for OpenApi managed_identity authentication. + public partial class OpenApiManagedAuthDetails : OpenApiAuthDetails + { + /// Initializes a new instance of . + /// Connection auth security details. + /// is null. + public OpenApiManagedAuthDetails(OpenApiManagedSecurityScheme securityScheme) + { + Argument.AssertNotNull(securityScheme, nameof(securityScheme)); + + Type = OpenApiAuthType.ManagedIdentity; + SecurityScheme = securityScheme; + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/connection/managed_identity. + /// Keeps track of any properties unknown to the library. + /// Connection auth security details. + internal OpenApiManagedAuthDetails(OpenApiAuthType type, IDictionary serializedAdditionalRawData, OpenApiManagedSecurityScheme securityScheme) : base(type, serializedAdditionalRawData) + { + SecurityScheme = securityScheme; + } + + /// Initializes a new instance of for deserialization. + internal OpenApiManagedAuthDetails() + { + } + + /// Connection auth security details. + public OpenApiManagedSecurityScheme SecurityScheme { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs new file mode 100644 index 000000000000..a7649a6bf7ba --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class OpenApiManagedSecurityScheme : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var 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" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OpenApiManagedSecurityScheme IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiManagedSecurityScheme(document.RootElement, options); + } + + internal static OpenApiManagedSecurityScheme DeserializeOpenApiManagedSecurityScheme(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string audience = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("audience"u8)) + { + audience = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenApiManagedSecurityScheme(audience, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support writing '{options.Format}' format."); + } + } + + OpenApiManagedSecurityScheme IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiManagedSecurityScheme(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OpenApiManagedSecurityScheme FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiManagedSecurityScheme(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedSecurityScheme.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedSecurityScheme.cs new file mode 100644 index 000000000000..dad65db653bb --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiManagedSecurityScheme.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Security scheme for OpenApi managed_identity authentication. + public partial class OpenApiManagedSecurityScheme + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// 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 serializedAdditionalRawData) + { + Audience = audience; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OpenApiManagedSecurityScheme() + { + } + + /// Authentication scope for managed_identity auth type. + public string Audience { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiToolDefinition.Serialization.cs new file mode 100644 index 000000000000..f32147eaa412 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiToolDefinition.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class OpenApiToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("openapi"u8); + writer.WriteObjectValue(Openapi, options); + } + + OpenApiToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiToolDefinition(document.RootElement, options); + } + + internal static OpenApiToolDefinition DeserializeOpenApiToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiFunctionDefinition openapi = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("openapi"u8)) + { + openapi = OpenApiFunctionDefinition.DeserializeOpenApiFunctionDefinition(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OpenApiToolDefinition(type, serializedAdditionalRawData, openapi); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenApiToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + OpenApiToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new OpenApiToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiToolDefinition.cs new file mode 100644 index 000000000000..ad7371687ccc --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/OpenApiToolDefinition.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for an OpenAPI tool as used to configure an agent. + public partial class OpenApiToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + /// The openapi function definition. + /// is null. + public OpenApiToolDefinition(OpenApiFunctionDefinition openapi) + { + Argument.AssertNotNull(openapi, nameof(openapi)); + + Type = "openapi"; + Openapi = openapi; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The openapi function definition. + internal OpenApiToolDefinition(string type, IDictionary serializedAdditionalRawData, OpenApiFunctionDefinition openapi) : base(type, serializedAdditionalRawData) + { + Openapi = openapi; + } + + /// Initializes a new instance of for deserialization. + internal OpenApiToolDefinition() + { + } + + /// The openapi function definition. + public OpenApiFunctionDefinition Openapi { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgent.Serialization.cs new file mode 100644 index 000000000000..5d0e1a9e8260 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgent.Serialization.cs @@ -0,0 +1,379 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class PersistentAgent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PersistentAgent)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + if (Name != null) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + else + { + writer.WriteNull("name"); + } + if (Description != null) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + else + { + writer.WriteNull("description"); + } + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + if (Instructions != null) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); + } + else + { + writer.WriteNull("instructions"); + } + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); + } + } + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PersistentAgent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PersistentAgent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePersistentAgent(document.RootElement, options); + } + + internal static PersistentAgent DeserializePersistentAgent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + PersistentAgentObject @object = default; + DateTimeOffset createdAt = default; + string name = default; + string description = default; + string model = default; + string instructions = default; + IReadOnlyList tools = default; + ToolResources toolResources = default; + float? temperature = default; + float? topP = default; + BinaryData responseFormat = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new PersistentAgentObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + name = null; + continue; + } + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + description = null; + continue; + } + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + instructions = null; + continue; + } + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); + } + tools = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; + } + responseFormat = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PersistentAgent( + id, + @object, + createdAt, + name, + description, + model, + instructions, + tools, + toolResources, + temperature, + topP, + responseFormat, + metadata, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PersistentAgent)} does not support writing '{options.Format}' format."); + } + } + + PersistentAgent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePersistentAgent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PersistentAgent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PersistentAgent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePersistentAgent(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgent.cs new file mode 100644 index 000000000000..f621e49b7367 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgent.cs @@ -0,0 +1,238 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents an agent that can call the model and use tools. + public partial class PersistentAgent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The name of the agent. + /// The description of the agent. + /// The ID of the model to use. + /// The system instructions for the agent to use. + /// + /// The collection of tools enabled for the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// 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. + /// + /// + /// 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 set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// , or is null. + internal PersistentAgent(string id, DateTimeOffset createdAt, string name, string description, string model, string instructions, IEnumerable tools, ToolResources toolResources, float? temperature, float? topP, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(model, nameof(model)); + Argument.AssertNotNull(tools, nameof(tools)); + + Id = id; + CreatedAt = createdAt; + Name = name; + Description = description; + Model = model; + Instructions = instructions; + Tools = tools.ToList(); + ToolResources = toolResources; + Temperature = temperature; + TopP = topP; + Metadata = metadata; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always assistant. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The name of the agent. + /// The description of the agent. + /// The ID of the model to use. + /// The system instructions for the agent to use. + /// + /// The collection of tools enabled for the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The response format of the tool calls used by this agent. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal PersistentAgent(string id, PersistentAgentObject @object, DateTimeOffset createdAt, string name, string description, string model, string instructions, IReadOnlyList tools, ToolResources toolResources, float? temperature, float? topP, BinaryData responseFormat, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + Name = name; + Description = description; + Model = model; + Instructions = instructions; + Tools = tools; + ToolResources = toolResources; + Temperature = temperature; + TopP = topP; + ResponseFormat = responseFormat; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PersistentAgent() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always assistant. + public PersistentAgentObject Object { get; } = PersistentAgentObject.Assistant; + + /// The Unix timestamp, in seconds, representing when this object was created. + public DateTimeOffset CreatedAt { get; } + /// The name of the agent. + public string Name { get; } + /// The description of the agent. + public string Description { get; } + /// The ID of the model to use. + public string Model { get; } + /// The system instructions for the agent to use. + public string Instructions { get; } + /// + /// The collection of tools enabled for the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + public IReadOnlyList Tools { get; } + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + public ToolResources ToolResources { 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. + /// + 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; } + /// + /// The response format of the tool calls used by this agent. + /// + /// 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 ResponseFormat { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentObject.cs new file mode 100644 index 000000000000..329509cededd --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The PersistentAgent_object. + public readonly partial struct PersistentAgentObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PersistentAgentObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AssistantValue = "assistant"; + + /// assistant. + public static PersistentAgentObject Assistant { get; } = new PersistentAgentObject(AssistantValue); + /// Determines if two values are the same. + public static bool operator ==(PersistentAgentObject left, PersistentAgentObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PersistentAgentObject left, PersistentAgentObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PersistentAgentObject(string value) => new PersistentAgentObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PersistentAgentObject other && Equals(other); + /// + public bool Equals(PersistentAgentObject 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.Agents.Persistent/src/Generated/PersistentAgentStreamEvent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentStreamEvent.cs new file mode 100644 index 000000000000..436afac3cea6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentStreamEvent.cs @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// Each event in a server-sent events stream has an `event` and `data` property: + /// + /// ``` + /// event: thread.created + /// data: {"id": "thread_123", "object": "thread", ...} + /// ``` + /// + /// We emit events whenever a new object is created, transitions to a new state, or is being + /// streamed in parts (deltas). For example, we emit `thread.run.created` when a new run + /// is created, `thread.run.completed` when a run completes, and so on. When an Agent chooses + /// to create a message during a run, we emit a `thread.message.created event`, a + /// `thread.message.in_progress` event, many `thread.message.delta` events, and finally a + /// `thread.message.completed` event. + /// + /// We may add additional events over time, so we recommend handling unknown events gracefully + /// in your code. + /// + public readonly partial struct PersistentAgentStreamEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PersistentAgentStreamEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadCreatedValue = "thread.created"; + private const string ThreadRunCreatedValue = "thread.run.created"; + private const string ThreadRunQueuedValue = "thread.run.queued"; + private const string ThreadRunInProgressValue = "thread.run.in_progress"; + private const string ThreadRunRequiresActionValue = "thread.run.requires_action"; + private const string ThreadRunCompletedValue = "thread.run.completed"; + private const string ThreadRunIncompleteValue = "thread.run.incomplete"; + private const string ThreadRunFailedValue = "thread.run.failed"; + private const string ThreadRunCancellingValue = "thread.run.cancelling"; + private const string ThreadRunCancelledValue = "thread.run.cancelled"; + private const string ThreadRunExpiredValue = "thread.run.expired"; + private const string ThreadRunStepCreatedValue = "thread.run.step.created"; + private const string ThreadRunStepInProgressValue = "thread.run.step.in_progress"; + private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; + private const string ThreadRunStepCompletedValue = "thread.run.step.completed"; + private const string ThreadRunStepFailedValue = "thread.run.step.failed"; + private const string ThreadRunStepCancelledValue = "thread.run.step.cancelled"; + private const string ThreadRunStepExpiredValue = "thread.run.step.expired"; + private const string ThreadMessageCreatedValue = "thread.message.created"; + private const string ThreadMessageInProgressValue = "thread.message.in_progress"; + private const string ThreadMessageDeltaValue = "thread.message.delta"; + private const string ThreadMessageCompletedValue = "thread.message.completed"; + private const string ThreadMessageIncompleteValue = "thread.message.incomplete"; + private const string ErrorValue = "error"; + private const string DoneValue = "done"; + + /// Event sent when a new thread is created. The data of this event is of type AgentThread. + public static PersistentAgentStreamEvent ThreadCreated { get; } = new PersistentAgentStreamEvent(ThreadCreatedValue); + /// Event sent when a new run is created. The data of this event is of type ThreadRun. + public static PersistentAgentStreamEvent ThreadRunCreated { get; } = new PersistentAgentStreamEvent(ThreadRunCreatedValue); + /// Event sent when a run moves to `queued` status. The data of this event is of type ThreadRun. + public static PersistentAgentStreamEvent ThreadRunQueued { get; } = new PersistentAgentStreamEvent(ThreadRunQueuedValue); + /// Event sent when a run moves to `in_progress` status. The data of this event is of type ThreadRun. + public static PersistentAgentStreamEvent ThreadRunInProgress { get; } = new PersistentAgentStreamEvent(ThreadRunInProgressValue); + /// Event sent when a run moves to `requires_action` status. The data of this event is of type ThreadRun. + public static PersistentAgentStreamEvent ThreadRunRequiresAction { get; } = new PersistentAgentStreamEvent(ThreadRunRequiresActionValue); + /// Event sent when a run is completed. The data of this event is of type ThreadRun. + public static PersistentAgentStreamEvent ThreadRunCompleted { get; } = new PersistentAgentStreamEvent(ThreadRunCompletedValue); + /// Event sent when a run ends incomplete. The data of this event is of type ThreadRun. + public static PersistentAgentStreamEvent ThreadRunIncomplete { get; } = new PersistentAgentStreamEvent(ThreadRunIncompleteValue); + /// Event sent when a run fails. The data of this event is of type ThreadRun. + public static PersistentAgentStreamEvent ThreadRunFailed { get; } = new PersistentAgentStreamEvent(ThreadRunFailedValue); + /// Event sent when a run moves to `cancelling` status. The data of this event is of type ThreadRun. + public static PersistentAgentStreamEvent ThreadRunCancelling { get; } = new PersistentAgentStreamEvent(ThreadRunCancellingValue); + /// Event sent when a run is cancelled. The data of this event is of type ThreadRun. + public static PersistentAgentStreamEvent ThreadRunCancelled { get; } = new PersistentAgentStreamEvent(ThreadRunCancelledValue); + /// Event sent when a run is expired. The data of this event is of type ThreadRun. + public static PersistentAgentStreamEvent ThreadRunExpired { get; } = new PersistentAgentStreamEvent(ThreadRunExpiredValue); + /// Event sent when a new thread run step is created. The data of this event is of type RunStep. + public static PersistentAgentStreamEvent ThreadRunStepCreated { get; } = new PersistentAgentStreamEvent(ThreadRunStepCreatedValue); + /// Event sent when a run step moves to `in_progress` status. The data of this event is of type RunStep. + public static PersistentAgentStreamEvent ThreadRunStepInProgress { get; } = new PersistentAgentStreamEvent(ThreadRunStepInProgressValue); + /// Event sent when a run step is being streamed. The data of this event is of type RunStepDeltaChunk. + public static PersistentAgentStreamEvent ThreadRunStepDelta { get; } = new PersistentAgentStreamEvent(ThreadRunStepDeltaValue); + /// Event sent when a run step is completed. The data of this event is of type RunStep. + public static PersistentAgentStreamEvent ThreadRunStepCompleted { get; } = new PersistentAgentStreamEvent(ThreadRunStepCompletedValue); + /// Event sent when a run step fails. The data of this event is of type RunStep. + public static PersistentAgentStreamEvent ThreadRunStepFailed { get; } = new PersistentAgentStreamEvent(ThreadRunStepFailedValue); + /// Event sent when a run step is cancelled. The data of this event is of type RunStep. + public static PersistentAgentStreamEvent ThreadRunStepCancelled { get; } = new PersistentAgentStreamEvent(ThreadRunStepCancelledValue); + /// Event sent when a run step is expired. The data of this event is of type RunStep. + public static PersistentAgentStreamEvent ThreadRunStepExpired { get; } = new PersistentAgentStreamEvent(ThreadRunStepExpiredValue); + /// Event sent when a new message is created. The data of this event is of type ThreadMessage. + public static PersistentAgentStreamEvent ThreadMessageCreated { get; } = new PersistentAgentStreamEvent(ThreadMessageCreatedValue); + /// Event sent when a message moves to `in_progress` status. The data of this event is of type ThreadMessage. + public static PersistentAgentStreamEvent ThreadMessageInProgress { get; } = new PersistentAgentStreamEvent(ThreadMessageInProgressValue); + /// Event sent when a message is being streamed. The data of this event is of type MessageDeltaChunk. + public static PersistentAgentStreamEvent ThreadMessageDelta { get; } = new PersistentAgentStreamEvent(ThreadMessageDeltaValue); + /// Event sent when a message is completed. The data of this event is of type ThreadMessage. + public static PersistentAgentStreamEvent ThreadMessageCompleted { get; } = new PersistentAgentStreamEvent(ThreadMessageCompletedValue); + /// Event sent before a message is completed. The data of this event is of type ThreadMessage. + public static PersistentAgentStreamEvent ThreadMessageIncomplete { get; } = new PersistentAgentStreamEvent(ThreadMessageIncompleteValue); + /// Event sent when an error occurs, such as an internal server error or a timeout. + public static PersistentAgentStreamEvent Error { get; } = new PersistentAgentStreamEvent(ErrorValue); + /// Event sent when the stream is done. + public static PersistentAgentStreamEvent Done { get; } = new PersistentAgentStreamEvent(DoneValue); + /// Determines if two values are the same. + public static bool operator ==(PersistentAgentStreamEvent left, PersistentAgentStreamEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PersistentAgentStreamEvent left, PersistentAgentStreamEvent right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PersistentAgentStreamEvent(string value) => new PersistentAgentStreamEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PersistentAgentStreamEvent other && Equals(other); + /// + public bool Equals(PersistentAgentStreamEvent 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.Agents.Persistent/src/Generated/PersistentAgentThread.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThread.Serialization.cs new file mode 100644 index 000000000000..f754d5f19ebd --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThread.Serialization.cs @@ -0,0 +1,215 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class PersistentAgentThread : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PersistentAgentThread)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PersistentAgentThread IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PersistentAgentThread)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePersistentAgentThread(document.RootElement, options); + } + + internal static PersistentAgentThread DeserializePersistentAgentThread(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + PersistentAgentThreadObject @object = default; + DateTimeOffset createdAt = default; + ToolResources toolResources = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new PersistentAgentThreadObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PersistentAgentThread( + id, + @object, + createdAt, + toolResources, + metadata, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PersistentAgentThread)} does not support writing '{options.Format}' format."); + } + } + + PersistentAgentThread IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePersistentAgentThread(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PersistentAgentThread)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PersistentAgentThread FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePersistentAgentThread(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThread.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThread.cs new file mode 100644 index 000000000000..f7b4fed408a7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThread.cs @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Information about a single thread associated with an agent. + public partial class PersistentAgentThread + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The Unix timestamp, in seconds, representing when this object was created. + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type + /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list + /// of vector store IDs. + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// is null. + internal PersistentAgentThread(string id, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + CreatedAt = createdAt; + ToolResources = toolResources; + Metadata = metadata; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'thread'. + /// The Unix timestamp, in seconds, representing when this object was created. + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type + /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list + /// of vector store IDs. + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal PersistentAgentThread(string id, PersistentAgentThreadObject @object, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + ToolResources = toolResources; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PersistentAgentThread() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always 'thread'. + public PersistentAgentThreadObject Object { get; } = PersistentAgentThreadObject.Thread; + + /// The Unix timestamp, in seconds, representing when this object was created. + public DateTimeOffset CreatedAt { get; } + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type + /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list + /// of vector store IDs. + /// + public ToolResources ToolResources { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadCreationOptions.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadCreationOptions.Serialization.cs new file mode 100644 index 000000000000..8c37cbf4622f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadCreationOptions.Serialization.cs @@ -0,0 +1,215 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class PersistentAgentThreadCreationOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PersistentAgentThreadCreationOptions)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Messages)) + { + writer.WritePropertyName("messages"u8); + writer.WriteStartArray(); + foreach (var item in Messages) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PersistentAgentThreadCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PersistentAgentThreadCreationOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePersistentAgentThreadCreationOptions(document.RootElement, options); + } + + internal static PersistentAgentThreadCreationOptions DeserializePersistentAgentThreadCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList messages = default; + ToolResources toolResources = default; + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ThreadMessageOptions.DeserializeThreadMessageOptions(item, options)); + } + messages = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PersistentAgentThreadCreationOptions(messages ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PersistentAgentThreadCreationOptions)} does not support writing '{options.Format}' format."); + } + } + + PersistentAgentThreadCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePersistentAgentThreadCreationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PersistentAgentThreadCreationOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PersistentAgentThreadCreationOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePersistentAgentThreadCreationOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadCreationOptions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadCreationOptions.cs new file mode 100644 index 000000000000..ec8eecc3be8d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadCreationOptions.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The details used to create a new agent thread. + public partial class PersistentAgentThreadCreationOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public PersistentAgentThreadCreationOptions() + { + Messages = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The initial messages to associate with the new thread. + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs. + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal PersistentAgentThreadCreationOptions(IList messages, ToolResources toolResources, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Messages = messages; + ToolResources = toolResources; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The initial messages to associate with the new thread. + public IList Messages { get; } + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs. + /// + public ToolResources ToolResources { get; set; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IDictionary Metadata { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadObject.cs new file mode 100644 index 000000000000..6458f03e4115 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentThreadObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The PersistentAgentThread_object. + public readonly partial struct PersistentAgentThreadObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PersistentAgentThreadObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadValue = "thread"; + + /// thread. + public static PersistentAgentThreadObject Thread { get; } = new PersistentAgentThreadObject(ThreadValue); + /// Determines if two values are the same. + public static bool operator ==(PersistentAgentThreadObject left, PersistentAgentThreadObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PersistentAgentThreadObject left, PersistentAgentThreadObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PersistentAgentThreadObject(string value) => new PersistentAgentThreadObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PersistentAgentThreadObject other && Equals(other); + /// + public bool Equals(PersistentAgentThreadObject 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.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormat.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormat.Serialization.cs new file mode 100644 index 000000000000..ffd4b50ec6ab --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormat.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class PersistentAgentsApiResponseFormat : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PersistentAgentsApiResponseFormat)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PersistentAgentsApiResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PersistentAgentsApiResponseFormat)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePersistentAgentsApiResponseFormat(document.RootElement, options); + } + + internal static PersistentAgentsApiResponseFormat DeserializePersistentAgentsApiResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseFormat? type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new ResponseFormat(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PersistentAgentsApiResponseFormat(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PersistentAgentsApiResponseFormat)} does not support writing '{options.Format}' format."); + } + } + + PersistentAgentsApiResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePersistentAgentsApiResponseFormat(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PersistentAgentsApiResponseFormat)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PersistentAgentsApiResponseFormat FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePersistentAgentsApiResponseFormat(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormat.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormat.cs new file mode 100644 index 000000000000..7f621cffaa46 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormat.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. + /// If `text` the model can return text or any value needed. + /// + public partial class PersistentAgentsApiResponseFormat + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public PersistentAgentsApiResponseFormat() + { + } + + /// Initializes a new instance of . + /// Must be one of `text` or `json_object`. + /// Keeps track of any properties unknown to the library. + internal PersistentAgentsApiResponseFormat(ResponseFormat? type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Must be one of `text` or `json_object`. + public ResponseFormat? Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormatMode.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormatMode.cs new file mode 100644 index 000000000000..99251836260c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiResponseFormatMode.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the mode in which the model will handle the return format of a tool call. + public readonly partial struct PersistentAgentsApiResponseFormatMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PersistentAgentsApiResponseFormatMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutoValue = "auto"; + private const string NoneValue = "none"; + + /// Default value. Let the model handle the return format. + public static PersistentAgentsApiResponseFormatMode Auto { get; } = new PersistentAgentsApiResponseFormatMode(AutoValue); + /// Setting the value to `none`, will result in a 400 Bad request. + public static PersistentAgentsApiResponseFormatMode None { get; } = new PersistentAgentsApiResponseFormatMode(NoneValue); + /// Determines if two values are the same. + public static bool operator ==(PersistentAgentsApiResponseFormatMode left, PersistentAgentsApiResponseFormatMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PersistentAgentsApiResponseFormatMode left, PersistentAgentsApiResponseFormatMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PersistentAgentsApiResponseFormatMode(string value) => new PersistentAgentsApiResponseFormatMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PersistentAgentsApiResponseFormatMode other && Equals(other); + /// + public bool Equals(PersistentAgentsApiResponseFormatMode 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.Agents.Persistent/src/Generated/PersistentAgentsApiToolChoiceOptionMode.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiToolChoiceOptionMode.cs new file mode 100644 index 000000000000..af838b9a4b47 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsApiToolChoiceOptionMode.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Specifies how the tool choice will be used. + public readonly partial struct PersistentAgentsApiToolChoiceOptionMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PersistentAgentsApiToolChoiceOptionMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "none"; + private const string AutoValue = "auto"; + + /// The model will not call a function and instead generates a message. + public static PersistentAgentsApiToolChoiceOptionMode None { get; } = new PersistentAgentsApiToolChoiceOptionMode(NoneValue); + /// The model can pick between generating a message or calling a function. + public static PersistentAgentsApiToolChoiceOptionMode Auto { get; } = new PersistentAgentsApiToolChoiceOptionMode(AutoValue); + /// Determines if two values are the same. + public static bool operator ==(PersistentAgentsApiToolChoiceOptionMode left, PersistentAgentsApiToolChoiceOptionMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PersistentAgentsApiToolChoiceOptionMode left, PersistentAgentsApiToolChoiceOptionMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PersistentAgentsApiToolChoiceOptionMode(string value) => new PersistentAgentsApiToolChoiceOptionMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PersistentAgentsApiToolChoiceOptionMode other && Equals(other); + /// + public bool Equals(PersistentAgentsApiToolChoiceOptionMode 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.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoice.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoice.Serialization.cs new file mode 100644 index 000000000000..bdf0d3ce385d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoice.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class PersistentAgentsNamedToolChoice : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PersistentAgentsNamedToolChoice)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsDefined(Function)) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PersistentAgentsNamedToolChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PersistentAgentsNamedToolChoice)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePersistentAgentsNamedToolChoice(document.RootElement, options); + } + + internal static PersistentAgentsNamedToolChoice DeserializePersistentAgentsNamedToolChoice(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PersistentAgentsNamedToolChoiceType type = default; + FunctionName function = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new PersistentAgentsNamedToolChoiceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("function"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + function = FunctionName.DeserializeFunctionName(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PersistentAgentsNamedToolChoice(type, function, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PersistentAgentsNamedToolChoice)} does not support writing '{options.Format}' format."); + } + } + + PersistentAgentsNamedToolChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePersistentAgentsNamedToolChoice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PersistentAgentsNamedToolChoice)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PersistentAgentsNamedToolChoice FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePersistentAgentsNamedToolChoice(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoice.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoice.cs new file mode 100644 index 000000000000..c79eac952589 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoice.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Specifies a tool the model should use. Use to force the model to call a specific tool. + public partial class PersistentAgentsNamedToolChoice + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// the type of tool. If type is `function`, the function name must be set. + public PersistentAgentsNamedToolChoice(PersistentAgentsNamedToolChoiceType type) + { + Type = type; + } + + /// Initializes a new instance of . + /// the type of tool. If type is `function`, the function name must be set. + /// The name of the function to call. + /// Keeps track of any properties unknown to the library. + internal PersistentAgentsNamedToolChoice(PersistentAgentsNamedToolChoiceType type, FunctionName function, IDictionary serializedAdditionalRawData) + { + Type = type; + Function = function; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PersistentAgentsNamedToolChoice() + { + } + + /// the type of tool. If type is `function`, the function name must be set. + public PersistentAgentsNamedToolChoiceType Type { get; set; } + /// The name of the function to call. + public FunctionName Function { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoiceType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoiceType.cs new file mode 100644 index 000000000000..5abd0fa864fd --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/PersistentAgentsNamedToolChoiceType.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Available tool types for agents named tools. + public readonly partial struct PersistentAgentsNamedToolChoiceType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PersistentAgentsNamedToolChoiceType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FunctionValue = "function"; + private const string CodeInterpreterValue = "code_interpreter"; + private const string FileSearchValue = "file_search"; + private const string BingGroundingValue = "bing_grounding"; + private const string MicrosoftFabricValue = "fabric_dataagent"; + private const string SharepointValue = "sharepoint_grounding"; + private const string AzureAISearchValue = "azure_ai_search"; + private const string BingCustomSearchValue = "bing_custom_search"; + private const string ConnectedAgentValue = "connected_agent"; + + /// Tool type `function`. + public static PersistentAgentsNamedToolChoiceType Function { get; } = new PersistentAgentsNamedToolChoiceType(FunctionValue); + /// Tool type `code_interpreter`. + public static PersistentAgentsNamedToolChoiceType CodeInterpreter { get; } = new PersistentAgentsNamedToolChoiceType(CodeInterpreterValue); + /// Tool type `file_search`. + public static PersistentAgentsNamedToolChoiceType FileSearch { get; } = new PersistentAgentsNamedToolChoiceType(FileSearchValue); + /// Tool type `bing_grounding`. + public static PersistentAgentsNamedToolChoiceType BingGrounding { get; } = new PersistentAgentsNamedToolChoiceType(BingGroundingValue); + /// Tool type `fabric_dataagent`. + public static PersistentAgentsNamedToolChoiceType MicrosoftFabric { get; } = new PersistentAgentsNamedToolChoiceType(MicrosoftFabricValue); + /// Tool type `sharepoint_grounding`. + public static PersistentAgentsNamedToolChoiceType Sharepoint { get; } = new PersistentAgentsNamedToolChoiceType(SharepointValue); + /// Tool type `azure_ai_search`. + public static PersistentAgentsNamedToolChoiceType AzureAISearch { get; } = new PersistentAgentsNamedToolChoiceType(AzureAISearchValue); + /// Tool type `bing_custom_search`. + public static PersistentAgentsNamedToolChoiceType BingCustomSearch { get; } = new PersistentAgentsNamedToolChoiceType(BingCustomSearchValue); + /// Tool type `connected_agent`. + public static PersistentAgentsNamedToolChoiceType ConnectedAgent { get; } = new PersistentAgentsNamedToolChoiceType(ConnectedAgentValue); + /// Determines if two values are the same. + public static bool operator ==(PersistentAgentsNamedToolChoiceType left, PersistentAgentsNamedToolChoiceType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PersistentAgentsNamedToolChoiceType left, PersistentAgentsNamedToolChoiceType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PersistentAgentsNamedToolChoiceType(string value) => new PersistentAgentsNamedToolChoiceType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PersistentAgentsNamedToolChoiceType other && Equals(other); + /// + public bool Equals(PersistentAgentsNamedToolChoiceType 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.Agents.Persistent/src/Generated/RequiredAction.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredAction.Serialization.cs new file mode 100644 index 000000000000..5eefa44e0a6f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredAction.Serialization.cs @@ -0,0 +1,133 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownRequiredAction))] + public partial class RequiredAction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredAction)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RequiredAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredAction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequiredAction(document.RootElement, options); + } + + internal static RequiredAction DeserializeRequiredAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "submit_tool_outputs": return SubmitToolOutputsAction.DeserializeSubmitToolOutputsAction(element, options); + } + } + return UnknownRequiredAction.DeserializeUnknownRequiredAction(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RequiredAction)} does not support writing '{options.Format}' format."); + } + } + + RequiredAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequiredAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredAction)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RequiredAction FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequiredAction(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredAction.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredAction.cs new file mode 100644 index 000000000000..cfcd4e5b3ff7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredAction.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An abstract representation of a required action for an agent thread run to continue. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public abstract partial class RequiredAction + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected RequiredAction() + { + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal RequiredAction(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredFunctionToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredFunctionToolCall.Serialization.cs new file mode 100644 index 000000000000..78841692a689 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredFunctionToolCall.Serialization.cs @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RequiredFunctionToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredFunctionToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(InternalDetails, options); + } + + RequiredFunctionToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredFunctionToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequiredFunctionToolCall(document.RootElement, options); + } + + internal static RequiredFunctionToolCall DeserializeRequiredFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalRequiredFunctionToolCallDetails function = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("function"u8)) + { + function = InternalRequiredFunctionToolCallDetails.DeserializeInternalRequiredFunctionToolCallDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RequiredFunctionToolCall(type, id, serializedAdditionalRawData, function); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RequiredFunctionToolCall)} does not support writing '{options.Format}' format."); + } + } + + RequiredFunctionToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequiredFunctionToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredFunctionToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RequiredFunctionToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequiredFunctionToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredFunctionToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredFunctionToolCall.cs new file mode 100644 index 000000000000..f9edbc403cb4 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredFunctionToolCall.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A representation of a requested call to a function tool, needed by the model to continue evaluation of a run. + public partial class RequiredFunctionToolCall : RequiredToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when submitting tool outputs. + /// Detailed information about the function to be executed by the tool that includes name and arguments. + /// or is null. + internal RequiredFunctionToolCall(string id, InternalRequiredFunctionToolCallDetails internalDetails) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(internalDetails, nameof(internalDetails)); + + Type = "function"; + InternalDetails = internalDetails; + } + + /// Initializes a new instance of . + /// The object type for the required tool call. + /// The ID of the tool call. This ID must be referenced when submitting tool outputs. + /// Keeps track of any properties unknown to the library. + /// Detailed information about the function to be executed by the tool that includes name and arguments. + internal RequiredFunctionToolCall(string type, string id, IDictionary serializedAdditionalRawData, InternalRequiredFunctionToolCallDetails internalDetails) : base(type, id, serializedAdditionalRawData) + { + InternalDetails = internalDetails; + } + + /// Initializes a new instance of for deserialization. + internal RequiredFunctionToolCall() + { + } + + /// Detailed information about the function to be executed by the tool that includes name and arguments. + public InternalRequiredFunctionToolCallDetails InternalDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredToolCall.Serialization.cs new file mode 100644 index 000000000000..3dcf96ad9950 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredToolCall.Serialization.cs @@ -0,0 +1,135 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownRequiredToolCall))] + public partial class RequiredToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RequiredToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequiredToolCall(document.RootElement, options); + } + + internal static RequiredToolCall DeserializeRequiredToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "function": return RequiredFunctionToolCall.DeserializeRequiredFunctionToolCall(element, options); + } + } + return UnknownRequiredToolCall.DeserializeUnknownRequiredToolCall(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support writing '{options.Format}' format."); + } + } + + RequiredToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequiredToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RequiredToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequiredToolCall(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredToolCall.cs new file mode 100644 index 000000000000..354a8eae184c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RequiredToolCall.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An abstract representation of a tool invocation needed by the model to continue a run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public abstract partial class RequiredToolCall + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when submitting tool outputs. + /// is null. + protected RequiredToolCall(string id) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + /// Initializes a new instance of . + /// The object type for the required tool call. + /// The ID of the tool call. This ID must be referenced when submitting tool outputs. + /// Keeps track of any properties unknown to the library. + internal RequiredToolCall(string type, string id, IDictionary serializedAdditionalRawData) + { + Type = type; + Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RequiredToolCall() + { + } + + /// The object type for the required tool call. + internal string Type { get; set; } + /// The ID of the tool call. This ID must be referenced when submitting tool outputs. + public string Id { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormat.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormat.cs new file mode 100644 index 000000000000..fad9a7c7c30e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormat.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Possible API response formats. + public readonly partial struct ResponseFormat : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ResponseFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TextValue = "text"; + private const string JsonObjectValue = "json_object"; + + /// `text` format should be used for requests involving any sort of ToolCall. + public static ResponseFormat Text { get; } = new ResponseFormat(TextValue); + /// Using `json_object` format will limit the usage of ToolCall to only functions. + public static ResponseFormat JsonObject { get; } = new ResponseFormat(JsonObjectValue); + /// Determines if two values are the same. + public static bool operator ==(ResponseFormat left, ResponseFormat right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ResponseFormat left, ResponseFormat right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ResponseFormat(string value) => new ResponseFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResponseFormat other && Equals(other); + /// + public bool Equals(ResponseFormat 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.Agents.Persistent/src/Generated/ResponseFormatJsonSchema.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchema.Serialization.cs new file mode 100644 index 000000000000..b59a1064efc3 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchema.Serialization.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ResponseFormatJsonSchema : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseFormatJsonSchema)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("schema"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Schema); +#else + using (JsonDocument document = JsonDocument.Parse(Schema, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ResponseFormatJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseFormatJsonSchema)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResponseFormatJsonSchema(document.RootElement, options); + } + + internal static ResponseFormatJsonSchema DeserializeResponseFormatJsonSchema(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string name = default; + BinaryData schema = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("schema"u8)) + { + schema = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResponseFormatJsonSchema(description, name, schema, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ResponseFormatJsonSchema)} does not support writing '{options.Format}' format."); + } + } + + ResponseFormatJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResponseFormatJsonSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResponseFormatJsonSchema)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ResponseFormatJsonSchema FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResponseFormatJsonSchema(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchema.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchema.cs new file mode 100644 index 000000000000..55ef7e6f3277 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchema.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A description of what the response format is for, used by the model to determine how to respond in the format. + public partial class ResponseFormatJsonSchema + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The name of a schema. + /// The JSON schema object, describing the response format. + /// or is null. + public ResponseFormatJsonSchema(string name, BinaryData schema) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(schema, nameof(schema)); + + Name = name; + Schema = schema; + } + + /// Initializes a new instance of . + /// A description of what the response format is for, used by the model to determine how to respond in the format. + /// The name of a schema. + /// The JSON schema object, describing the response format. + /// Keeps track of any properties unknown to the library. + internal ResponseFormatJsonSchema(string description, string name, BinaryData schema, IDictionary serializedAdditionalRawData) + { + Description = description; + Name = name; + Schema = schema; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ResponseFormatJsonSchema() + { + } + + /// 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 a schema. + public string Name { get; set; } + /// + /// The JSON schema object, describing the response format. + /// + /// 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.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaType.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaType.Serialization.cs new file mode 100644 index 000000000000..1a2d81631636 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaType.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ResponseFormatJsonSchemaType : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseFormatJsonSchemaType)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + writer.WritePropertyName("json_schema"u8); + writer.WriteObjectValue(JsonSchema, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ResponseFormatJsonSchemaType IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseFormatJsonSchemaType)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResponseFormatJsonSchemaType(document.RootElement, options); + } + + internal static ResponseFormatJsonSchemaType DeserializeResponseFormatJsonSchemaType(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseFormatJsonSchemaTypeType type = default; + ResponseFormatJsonSchema jsonSchema = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new ResponseFormatJsonSchemaTypeType(property.Value.GetString()); + continue; + } + if (property.NameEquals("json_schema"u8)) + { + jsonSchema = ResponseFormatJsonSchema.DeserializeResponseFormatJsonSchema(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResponseFormatJsonSchemaType(type, jsonSchema, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ResponseFormatJsonSchemaType)} does not support writing '{options.Format}' format."); + } + } + + ResponseFormatJsonSchemaType IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResponseFormatJsonSchemaType(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResponseFormatJsonSchemaType)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ResponseFormatJsonSchemaType FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResponseFormatJsonSchemaType(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaType.cs new file mode 100644 index 000000000000..81e86210ee9e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaType.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The type of response format being defined: `json_schema`. + public partial class ResponseFormatJsonSchemaType + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The JSON schema, describing response format. + /// is null. + public ResponseFormatJsonSchemaType(ResponseFormatJsonSchema jsonSchema) + { + Argument.AssertNotNull(jsonSchema, nameof(jsonSchema)); + + JsonSchema = jsonSchema; + } + + /// Initializes a new instance of . + /// Type. + /// The JSON schema, describing response format. + /// Keeps track of any properties unknown to the library. + internal ResponseFormatJsonSchemaType(ResponseFormatJsonSchemaTypeType type, ResponseFormatJsonSchema jsonSchema, IDictionary serializedAdditionalRawData) + { + Type = type; + JsonSchema = jsonSchema; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ResponseFormatJsonSchemaType() + { + } + + /// Type. + public ResponseFormatJsonSchemaTypeType Type { get; } = ResponseFormatJsonSchemaTypeType.JsonSchema; + + /// The JSON schema, describing response format. + public ResponseFormatJsonSchema JsonSchema { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaTypeType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaTypeType.cs new file mode 100644 index 000000000000..6b8b307b39a6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ResponseFormatJsonSchemaTypeType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The ResponseFormatJsonSchemaType_type. + public readonly partial struct ResponseFormatJsonSchemaTypeType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ResponseFormatJsonSchemaTypeType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string JsonSchemaValue = "json_schema"; + + /// json_schema. + public static ResponseFormatJsonSchemaTypeType JsonSchema { get; } = new ResponseFormatJsonSchemaTypeType(JsonSchemaValue); + /// Determines if two values are the same. + public static bool operator ==(ResponseFormatJsonSchemaTypeType left, ResponseFormatJsonSchemaTypeType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ResponseFormatJsonSchemaTypeType left, ResponseFormatJsonSchemaTypeType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ResponseFormatJsonSchemaTypeType(string value) => new ResponseFormatJsonSchemaTypeType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResponseFormatJsonSchemaTypeType other && Equals(other); + /// + public bool Equals(ResponseFormatJsonSchemaTypeType 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.Agents.Persistent/src/Generated/RunAdditionalFieldList.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunAdditionalFieldList.cs new file mode 100644 index 000000000000..9cb787a43555 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunAdditionalFieldList.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// A list of additional fields to include in the response. + public readonly partial struct RunAdditionalFieldList : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunAdditionalFieldList(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FileSearchContentsValue = "step_details.tool_calls[*].file_search.results[*].content"; + + /// File search result content. + public static RunAdditionalFieldList FileSearchContents { get; } = new RunAdditionalFieldList(FileSearchContentsValue); + /// Determines if two values are the same. + public static bool operator ==(RunAdditionalFieldList left, RunAdditionalFieldList right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunAdditionalFieldList left, RunAdditionalFieldList right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RunAdditionalFieldList(string value) => new RunAdditionalFieldList(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunAdditionalFieldList other && Equals(other); + /// + public bool Equals(RunAdditionalFieldList 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.Agents.Persistent/src/Generated/RunCompletionUsage.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunCompletionUsage.Serialization.cs new file mode 100644 index 000000000000..3d8e01156c54 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunCompletionUsage.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunCompletionUsage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunCompletionUsage)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("completion_tokens"u8); + writer.WriteNumberValue(CompletionTokens); + writer.WritePropertyName("prompt_tokens"u8); + writer.WriteNumberValue(PromptTokens); + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokens); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunCompletionUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunCompletionUsage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunCompletionUsage(document.RootElement, options); + } + + internal static RunCompletionUsage DeserializeRunCompletionUsage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long completionTokens = default; + long promptTokens = default; + long totalTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("completion_tokens"u8)) + { + completionTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("prompt_tokens"u8)) + { + promptTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("total_tokens"u8)) + { + totalTokens = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunCompletionUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunCompletionUsage)} does not support writing '{options.Format}' format."); + } + } + + RunCompletionUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunCompletionUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunCompletionUsage)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunCompletionUsage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunCompletionUsage(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunCompletionUsage.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunCompletionUsage.cs new file mode 100644 index 000000000000..2ba1f9d88eee --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunCompletionUsage.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + public partial class RunCompletionUsage + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run. + /// Number of prompt tokens used over the course of the run. + /// Total number of tokens used (prompt + completion). + internal RunCompletionUsage(long completionTokens, long promptTokens, long totalTokens) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + } + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run. + /// Number of prompt tokens used over the course of the run. + /// Total number of tokens used (prompt + completion). + /// Keeps track of any properties unknown to the library. + internal RunCompletionUsage(long completionTokens, long promptTokens, long totalTokens, IDictionary serializedAdditionalRawData) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunCompletionUsage() + { + } + + /// Number of completion tokens used over the course of the run. + public long CompletionTokens { get; } + /// Number of prompt tokens used over the course of the run. + public long PromptTokens { get; } + /// Total number of tokens used (prompt + completion). + public long TotalTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunError.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunError.Serialization.cs new file mode 100644 index 000000000000..ebbfd2a44ee5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunError.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunError)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunError)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunError(document.RootElement, options); + } + + internal static RunError DeserializeRunError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunError(code, message, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunError)} does not support writing '{options.Format}' format."); + } + } + + RunError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunError)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunError FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunError(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunError.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunError.cs new file mode 100644 index 000000000000..a72f75d7216f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunError.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The details of an error as encountered by an agent thread run. + public partial class RunError + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The status for the error. + /// The human-readable text associated with the error. + /// or is null. + internal RunError(string code, string message) + { + Argument.AssertNotNull(code, nameof(code)); + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + } + + /// Initializes a new instance of . + /// The status for the error. + /// The human-readable text associated with the error. + /// Keeps track of any properties unknown to the library. + internal RunError(string code, string message, IDictionary serializedAdditionalRawData) + { + Code = code; + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunError() + { + } + + /// The status for the error. + public string Code { get; } + /// The human-readable text associated with the error. + public string Message { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStatus.cs new file mode 100644 index 000000000000..9ad6ab5668c2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStatus.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Possible values for the status of an agent thread run. + public readonly partial struct RunStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string QueuedValue = "queued"; + private const string InProgressValue = "in_progress"; + private const string RequiresActionValue = "requires_action"; + private const string CancellingValue = "cancelling"; + private const string CancelledValue = "cancelled"; + private const string FailedValue = "failed"; + private const string CompletedValue = "completed"; + private const string ExpiredValue = "expired"; + + /// Represents a run that is queued to start. + public static RunStatus Queued { get; } = new RunStatus(QueuedValue); + /// Represents a run that is in progress. + public static RunStatus InProgress { get; } = new RunStatus(InProgressValue); + /// Represents a run that needs another operation, such as tool output submission, to continue. + public static RunStatus RequiresAction { get; } = new RunStatus(RequiresActionValue); + /// Represents a run that is in the process of cancellation. + public static RunStatus Cancelling { get; } = new RunStatus(CancellingValue); + /// Represents a run that has been cancelled. + public static RunStatus Cancelled { get; } = new RunStatus(CancelledValue); + /// Represents a run that failed. + public static RunStatus Failed { get; } = new RunStatus(FailedValue); + /// Represents a run that successfully completed. + public static RunStatus Completed { get; } = new RunStatus(CompletedValue); + /// Represents a run that expired before it could otherwise finish. + public static RunStatus Expired { get; } = new RunStatus(ExpiredValue); + /// Determines if two values are the same. + public static bool operator ==(RunStatus left, RunStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStatus left, RunStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RunStatus(string value) => new RunStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStatus other && Equals(other); + /// + public bool Equals(RunStatus 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.Agents.Persistent/src/Generated/RunStep.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStep.Serialization.cs new file mode 100644 index 000000000000..53bb43682a26 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStep.Serialization.cs @@ -0,0 +1,377 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStep : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStep)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + writer.WritePropertyName("assistant_id"u8); + writer.WriteStringValue(AssistantId); + writer.WritePropertyName("thread_id"u8); + writer.WriteStringValue(ThreadId); + writer.WritePropertyName("run_id"u8); + writer.WriteStringValue(RunId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("step_details"u8); + writer.WriteObjectValue(StepDetails, options); + if (LastError != null) + { + writer.WritePropertyName("last_error"u8); + writer.WriteObjectValue(LastError, options); + } + else + { + writer.WriteNull("last_error"); + } + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + if (ExpiredAt != null) + { + writer.WritePropertyName("expired_at"u8); + writer.WriteNumberValue(ExpiredAt.Value, "U"); + } + else + { + writer.WriteNull("expired_at"); + } + if (CompletedAt != null) + { + writer.WritePropertyName("completed_at"u8); + writer.WriteNumberValue(CompletedAt.Value, "U"); + } + else + { + writer.WriteNull("completed_at"); + } + if (CancelledAt != null) + { + writer.WritePropertyName("cancelled_at"u8); + writer.WriteNumberValue(CancelledAt.Value, "U"); + } + else + { + writer.WriteNull("cancelled_at"); + } + if (FailedAt != null) + { + writer.WritePropertyName("failed_at"u8); + writer.WriteNumberValue(FailedAt.Value, "U"); + } + else + { + writer.WriteNull("failed_at"); + } + if (Optional.IsDefined(Usage)) + { + if (Usage != null) + { + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + } + else + { + writer.WriteNull("usage"); + } + } + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStep IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStep)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStep(document.RootElement, options); + } + + internal static RunStep DeserializeRunStep(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + RunStepObject @object = default; + RunStepType type = default; + string assistantId = default; + string threadId = default; + string runId = default; + RunStepStatus status = default; + RunStepDetails stepDetails = default; + RunStepError lastError = default; + DateTimeOffset createdAt = default; + DateTimeOffset? expiredAt = default; + DateTimeOffset? completedAt = default; + DateTimeOffset? cancelledAt = default; + DateTimeOffset? failedAt = default; + RunStepCompletionUsage usage = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new RunStepObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new RunStepType(property.Value.GetString()); + continue; + } + if (property.NameEquals("assistant_id"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("thread_id"u8)) + { + threadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("run_id"u8)) + { + runId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new RunStepStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("step_details"u8)) + { + stepDetails = RunStepDetails.DeserializeRunStepDetails(property.Value, options); + continue; + } + if (property.NameEquals("last_error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastError = null; + continue; + } + lastError = RunStepError.DeserializeRunStepError(property.Value, options); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("expired_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + expiredAt = null; + continue; + } + expiredAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("completed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + completedAt = null; + continue; + } + completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("cancelled_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + cancelledAt = null; + continue; + } + cancelledAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("failed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + failedAt = null; + continue; + } + failedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("usage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + usage = null; + continue; + } + usage = RunStepCompletionUsage.DeserializeRunStepCompletionUsage(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStep( + id, + @object, + type, + assistantId, + threadId, + runId, + status, + stepDetails, + lastError, + createdAt, + expiredAt, + completedAt, + cancelledAt, + failedAt, + usage, + metadata, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStep)} does not support writing '{options.Format}' format."); + } + } + + RunStep IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStep(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStep)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStep FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStep(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStep.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStep.cs new file mode 100644 index 000000000000..2f3e3b57b1bf --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStep.cs @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Detailed information about a single step of an agent thread run. + public partial class RunStep + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The type of run step, which can be either message_creation or tool_calls. + /// The ID of the agent associated with the run step. + /// The ID of the thread that was run. + /// The ID of the run that this run step is a part of. + /// The status of this run step. + /// + /// The details for this run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// If applicable, information about the last error encountered by this run step. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The Unix timestamp, in seconds, representing when this item expired. + /// The Unix timestamp, in seconds, representing when this completed. + /// The Unix timestamp, in seconds, representing when this was cancelled. + /// The Unix timestamp, in seconds, representing when this failed. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// , , , or is null. + internal RunStep(string id, RunStepType type, string assistantId, string threadId, string runId, RunStepStatus status, RunStepDetails stepDetails, RunStepError lastError, DateTimeOffset createdAt, DateTimeOffset? expiredAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(assistantId, nameof(assistantId)); + Argument.AssertNotNull(threadId, nameof(threadId)); + Argument.AssertNotNull(runId, nameof(runId)); + Argument.AssertNotNull(stepDetails, nameof(stepDetails)); + + Id = id; + Type = type; + AssistantId = assistantId; + ThreadId = threadId; + RunId = runId; + Status = status; + StepDetails = stepDetails; + LastError = lastError; + CreatedAt = createdAt; + ExpiredAt = expiredAt; + CompletedAt = completedAt; + CancelledAt = cancelledAt; + FailedAt = failedAt; + Metadata = metadata; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'thread.run.step'. + /// The type of run step, which can be either message_creation or tool_calls. + /// The ID of the agent associated with the run step. + /// The ID of the thread that was run. + /// The ID of the run that this run step is a part of. + /// The status of this run step. + /// + /// The details for this run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// If applicable, information about the last error encountered by this run step. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The Unix timestamp, in seconds, representing when this item expired. + /// The Unix timestamp, in seconds, representing when this completed. + /// The Unix timestamp, in seconds, representing when this was cancelled. + /// The Unix timestamp, in seconds, representing when this failed. + /// Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal RunStep(string id, RunStepObject @object, RunStepType type, string assistantId, string threadId, string runId, RunStepStatus status, RunStepDetails stepDetails, RunStepError lastError, DateTimeOffset createdAt, DateTimeOffset? expiredAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, RunStepCompletionUsage usage, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + Type = type; + AssistantId = assistantId; + ThreadId = threadId; + RunId = runId; + Status = status; + StepDetails = stepDetails; + LastError = lastError; + CreatedAt = createdAt; + ExpiredAt = expiredAt; + CompletedAt = completedAt; + CancelledAt = cancelledAt; + FailedAt = failedAt; + Usage = usage; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStep() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always 'thread.run.step'. + public RunStepObject Object { get; } = RunStepObject.ThreadRunStep; + + /// The type of run step, which can be either message_creation or tool_calls. + public RunStepType Type { get; } + /// The ID of the agent associated with the run step. + public string AssistantId { get; } + /// The ID of the thread that was run. + public string ThreadId { get; } + /// The ID of the run that this run step is a part of. + public string RunId { get; } + /// The status of this run step. + public RunStepStatus Status { get; } + /// + /// The details for this run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public RunStepDetails StepDetails { get; } + /// If applicable, information about the last error encountered by this run step. + public RunStepError LastError { get; } + /// The Unix timestamp, in seconds, representing when this object was created. + public DateTimeOffset CreatedAt { get; } + /// The Unix timestamp, in seconds, representing when this item expired. + public DateTimeOffset? ExpiredAt { get; } + /// The Unix timestamp, in seconds, representing when this completed. + public DateTimeOffset? CompletedAt { get; } + /// The Unix timestamp, in seconds, representing when this was cancelled. + public DateTimeOffset? CancelledAt { get; } + /// The Unix timestamp, in seconds, representing when this failed. + public DateTimeOffset? FailedAt { get; } + /// Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + public RunStepCompletionUsage Usage { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepAzureAISearchToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepAzureAISearchToolCall.Serialization.cs new file mode 100644 index 000000000000..7a942a67a04c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepAzureAISearchToolCall.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepAzureAISearchToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepAzureAISearchToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("azure_ai_search"u8); + writer.WriteStartObject(); + foreach (var item in AzureAISearch) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + + RunStepAzureAISearchToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepAzureAISearchToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepAzureAISearchToolCall(document.RootElement, options); + } + + internal static RunStepAzureAISearchToolCall DeserializeRunStepAzureAISearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary azureAiSearch = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("azure_ai_search"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + azureAiSearch = dictionary; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepAzureAISearchToolCall(type, id, serializedAdditionalRawData, azureAiSearch); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepAzureAISearchToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepAzureAISearchToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepAzureAISearchToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepAzureAISearchToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepAzureAISearchToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepAzureAISearchToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepAzureAISearchToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepAzureAISearchToolCall.cs new file mode 100644 index 000000000000..ad27790312ec --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepAzureAISearchToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A record of a call to an Azure AI Search tool, issued by the model in evaluation of a defined tool, that represents + /// executed Azure AI search. + /// + public partial class RunStepAzureAISearchToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// or is null. + internal RunStepAzureAISearchToolCall(string id, IReadOnlyDictionary azureAISearch) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(azureAISearch, nameof(azureAISearch)); + + Type = "azure_ai_search"; + AzureAISearch = azureAISearch; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepAzureAISearchToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary azureAISearch) : base(type, id, serializedAdditionalRawData) + { + AzureAISearch = azureAISearch; + } + + /// Initializes a new instance of for deserialization. + internal RunStepAzureAISearchToolCall() + { + } + + /// Reserved for future use. + public IReadOnlyDictionary AzureAISearch { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepBingGroundingToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepBingGroundingToolCall.Serialization.cs new file mode 100644 index 000000000000..6478a1c1ae1c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepBingGroundingToolCall.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepBingGroundingToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepBingGroundingToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("bing_grounding"u8); + writer.WriteStartObject(); + foreach (var item in BingGrounding) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + + RunStepBingGroundingToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepBingGroundingToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepBingGroundingToolCall(document.RootElement, options); + } + + internal static RunStepBingGroundingToolCall DeserializeRunStepBingGroundingToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary bingGrounding = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("bing_grounding"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + bingGrounding = dictionary; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepBingGroundingToolCall(type, id, serializedAdditionalRawData, bingGrounding); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepBingGroundingToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepBingGroundingToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepBingGroundingToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepBingGroundingToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepBingGroundingToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepBingGroundingToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepBingGroundingToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepBingGroundingToolCall.cs new file mode 100644 index 000000000000..f1e11c513f6b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepBingGroundingToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A record of a call to a bing grounding tool, issued by the model in evaluation of a defined tool, that represents + /// executed search with bing grounding. + /// + public partial class RunStepBingGroundingToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// or is null. + internal RunStepBingGroundingToolCall(string id, IReadOnlyDictionary bingGrounding) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(bingGrounding, nameof(bingGrounding)); + + Type = "bing_grounding"; + BingGrounding = bingGrounding; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepBingGroundingToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary bingGrounding) : base(type, id, serializedAdditionalRawData) + { + BingGrounding = bingGrounding; + } + + /// Initializes a new instance of for deserialization. + internal RunStepBingGroundingToolCall() + { + } + + /// Reserved for future use. + public IReadOnlyDictionary BingGrounding { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageOutput.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageOutput.Serialization.cs new file mode 100644 index 000000000000..6d6f2f4862b7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageOutput.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class RunStepCodeInterpreterImageOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageOutput)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("image"u8); + writer.WriteObjectValue(Image, options); + } + + RunStepCodeInterpreterImageOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterImageOutput(document.RootElement, options); + } + + internal static RunStepCodeInterpreterImageOutput DeserializeRunStepCodeInterpreterImageOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepCodeInterpreterImageReference image = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image"u8)) + { + image = RunStepCodeInterpreterImageReference.DeserializeRunStepCodeInterpreterImageReference(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepCodeInterpreterImageOutput(type, serializedAdditionalRawData, image); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepCodeInterpreterImageOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterImageOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepCodeInterpreterImageOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterImageOutput(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageOutput.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageOutput.cs new file mode 100644 index 000000000000..4126c7e4d60e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageOutput.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A representation of an image output emitted by a code interpreter tool in response to a tool call by the model. + internal partial class RunStepCodeInterpreterImageOutput : RunStepCodeInterpreterToolCallOutput + { + /// Initializes a new instance of . + /// Referential information for the image associated with this output. + /// is null. + internal RunStepCodeInterpreterImageOutput(RunStepCodeInterpreterImageReference image) + { + Argument.AssertNotNull(image, nameof(image)); + + Type = "image"; + Image = image; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// Referential information for the image associated with this output. + internal RunStepCodeInterpreterImageOutput(string type, IDictionary serializedAdditionalRawData, RunStepCodeInterpreterImageReference image) : base(type, serializedAdditionalRawData) + { + Image = image; + } + + /// Initializes a new instance of for deserialization. + internal RunStepCodeInterpreterImageOutput() + { + } + + /// Referential information for the image associated with this output. + public RunStepCodeInterpreterImageReference Image { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageReference.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageReference.Serialization.cs new file mode 100644 index 000000000000..4936a8cd1757 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageReference.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class RunStepCodeInterpreterImageReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageReference)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepCodeInterpreterImageReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterImageReference(document.RootElement, options); + } + + internal static RunStepCodeInterpreterImageReference DeserializeRunStepCodeInterpreterImageReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepCodeInterpreterImageReference(fileId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageReference)} does not support writing '{options.Format}' format."); + } + } + + RunStepCodeInterpreterImageReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterImageReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageReference)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepCodeInterpreterImageReference FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterImageReference(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageReference.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageReference.cs new file mode 100644 index 000000000000..942f8e6641c1 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterImageReference.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// An image reference emitted by a code interpreter tool in response to a tool call by the model. + internal partial class RunStepCodeInterpreterImageReference + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the file associated with this image. + /// is null. + internal RunStepCodeInterpreterImageReference(string fileId) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + } + + /// Initializes a new instance of . + /// The ID of the file associated with this image. + /// Keeps track of any properties unknown to the library. + internal RunStepCodeInterpreterImageReference(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepCodeInterpreterImageReference() + { + } + + /// The ID of the file associated with this image. + public string FileId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterLogOutput.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterLogOutput.Serialization.cs new file mode 100644 index 000000000000..a658240714d9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterLogOutput.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class RunStepCodeInterpreterLogOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterLogOutput)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("logs"u8); + writer.WriteStringValue(Logs); + } + + RunStepCodeInterpreterLogOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterLogOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterLogOutput(document.RootElement, options); + } + + internal static RunStepCodeInterpreterLogOutput DeserializeRunStepCodeInterpreterLogOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string logs = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("logs"u8)) + { + logs = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepCodeInterpreterLogOutput(type, serializedAdditionalRawData, logs); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterLogOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepCodeInterpreterLogOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterLogOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterLogOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepCodeInterpreterLogOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterLogOutput(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterLogOutput.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterLogOutput.cs new file mode 100644 index 000000000000..81e90378443b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterLogOutput.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A representation of a log output emitted by a code interpreter tool in response to a tool call by the model. + internal partial class RunStepCodeInterpreterLogOutput : RunStepCodeInterpreterToolCallOutput + { + /// Initializes a new instance of . + /// The serialized log output emitted by the code interpreter. + /// is null. + internal RunStepCodeInterpreterLogOutput(string logs) + { + Argument.AssertNotNull(logs, nameof(logs)); + + Type = "logs"; + Logs = logs; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The serialized log output emitted by the code interpreter. + internal RunStepCodeInterpreterLogOutput(string type, IDictionary serializedAdditionalRawData, string logs) : base(type, serializedAdditionalRawData) + { + Logs = logs; + } + + /// Initializes a new instance of for deserialization. + internal RunStepCodeInterpreterLogOutput() + { + } + + /// The serialized log output emitted by the code interpreter. + public string Logs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCall.Serialization.cs new file mode 100644 index 000000000000..5733c0f55ccb --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCall.Serialization.cs @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepCodeInterpreterToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(InternalDetails, options); + } + + RunStepCodeInterpreterToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterToolCall(document.RootElement, options); + } + + internal static RunStepCodeInterpreterToolCall DeserializeRunStepCodeInterpreterToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCodeInterpreterToolCallDetails codeInterpreter = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) + { + codeInterpreter = InternalCodeInterpreterToolCallDetails.DeserializeInternalCodeInterpreterToolCallDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepCodeInterpreterToolCall(type, id, serializedAdditionalRawData, codeInterpreter); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepCodeInterpreterToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepCodeInterpreterToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCall.cs new file mode 100644 index 000000000000..1fcbc63acd91 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A record of a call to a code interpreter tool, issued by the model in evaluation of a defined tool, that + /// represents inputs and outputs consumed and emitted by the code interpreter. + /// + public partial class RunStepCodeInterpreterToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// The details of the tool call to the code interpreter tool. + /// or is null. + internal RunStepCodeInterpreterToolCall(string id, InternalCodeInterpreterToolCallDetails internalDetails) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(internalDetails, nameof(internalDetails)); + + Type = "code_interpreter"; + InternalDetails = internalDetails; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// The details of the tool call to the code interpreter tool. + internal RunStepCodeInterpreterToolCall(string type, string id, IDictionary serializedAdditionalRawData, InternalCodeInterpreterToolCallDetails internalDetails) : base(type, id, serializedAdditionalRawData) + { + InternalDetails = internalDetails; + } + + /// Initializes a new instance of for deserialization. + internal RunStepCodeInterpreterToolCall() + { + } + + /// The details of the tool call to the code interpreter tool. + public InternalCodeInterpreterToolCallDetails InternalDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs new file mode 100644 index 000000000000..270356b8464c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs @@ -0,0 +1,134 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownRunStepCodeInterpreterToolCallOutput))] + internal partial class RunStepCodeInterpreterToolCallOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepCodeInterpreterToolCallOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement, options); + } + + internal static RunStepCodeInterpreterToolCallOutput DeserializeRunStepCodeInterpreterToolCallOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "image": return RunStepCodeInterpreterImageOutput.DeserializeRunStepCodeInterpreterImageOutput(element, options); + case "logs": return RunStepCodeInterpreterLogOutput.DeserializeRunStepCodeInterpreterLogOutput(element, options); + } + } + return UnknownRunStepCodeInterpreterToolCallOutput.DeserializeUnknownRunStepCodeInterpreterToolCallOutput(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepCodeInterpreterToolCallOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepCodeInterpreterToolCallOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCallOutput.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCallOutput.cs new file mode 100644 index 000000000000..ff445b2691da --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCodeInterpreterToolCallOutput.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An abstract representation of an emitted output from a code interpreter tool. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + internal abstract partial class RunStepCodeInterpreterToolCallOutput + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected RunStepCodeInterpreterToolCallOutput() + { + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal RunStepCodeInterpreterToolCallOutput(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCompletionUsage.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCompletionUsage.Serialization.cs new file mode 100644 index 000000000000..e869652d7015 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCompletionUsage.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepCompletionUsage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCompletionUsage)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("completion_tokens"u8); + writer.WriteNumberValue(CompletionTokens); + writer.WritePropertyName("prompt_tokens"u8); + writer.WriteNumberValue(PromptTokens); + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokens); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepCompletionUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCompletionUsage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCompletionUsage(document.RootElement, options); + } + + internal static RunStepCompletionUsage DeserializeRunStepCompletionUsage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long completionTokens = default; + long promptTokens = default; + long totalTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("completion_tokens"u8)) + { + completionTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("prompt_tokens"u8)) + { + promptTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("total_tokens"u8)) + { + totalTokens = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepCompletionUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCompletionUsage)} does not support writing '{options.Format}' format."); + } + } + + RunStepCompletionUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCompletionUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCompletionUsage)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepCompletionUsage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCompletionUsage(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCompletionUsage.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCompletionUsage.cs new file mode 100644 index 000000000000..1999a6fb83c2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCompletionUsage.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Usage statistics related to the run step. + public partial class RunStepCompletionUsage + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run step. + /// Number of prompt tokens used over the course of the run step. + /// Total number of tokens used (prompt + completion). + internal RunStepCompletionUsage(long completionTokens, long promptTokens, long totalTokens) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + } + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run step. + /// Number of prompt tokens used over the course of the run step. + /// Total number of tokens used (prompt + completion). + /// Keeps track of any properties unknown to the library. + internal RunStepCompletionUsage(long completionTokens, long promptTokens, long totalTokens, IDictionary serializedAdditionalRawData) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepCompletionUsage() + { + } + + /// Number of completion tokens used over the course of the run step. + public long CompletionTokens { get; } + /// Number of prompt tokens used over the course of the run step. + public long PromptTokens { get; } + /// Total number of tokens used (prompt + completion). + public long TotalTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCustomSearchToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCustomSearchToolCall.Serialization.cs new file mode 100644 index 000000000000..b0bb130d831d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCustomSearchToolCall.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepCustomSearchToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCustomSearchToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("bing_custom_search"u8); + writer.WriteStartObject(); + foreach (var item in BingCustomSearch) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + + RunStepCustomSearchToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCustomSearchToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCustomSearchToolCall(document.RootElement, options); + } + + internal static RunStepCustomSearchToolCall DeserializeRunStepCustomSearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary bingCustomSearch = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("bing_custom_search"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + bingCustomSearch = dictionary; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepCustomSearchToolCall(type, id, serializedAdditionalRawData, bingCustomSearch); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCustomSearchToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepCustomSearchToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCustomSearchToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCustomSearchToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepCustomSearchToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCustomSearchToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCustomSearchToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCustomSearchToolCall.cs new file mode 100644 index 000000000000..1b3ccb0c4591 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepCustomSearchToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A record of a call to a bing custom search tool, issued by the model in evaluation of a defined tool, that represents + /// executed search with bing custom search. + /// + public partial class RunStepCustomSearchToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// or is null. + internal RunStepCustomSearchToolCall(string id, IReadOnlyDictionary bingCustomSearch) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(bingCustomSearch, nameof(bingCustomSearch)); + + Type = "bing_custom_search"; + BingCustomSearch = bingCustomSearch; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepCustomSearchToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary bingCustomSearch) : base(type, id, serializedAdditionalRawData) + { + BingCustomSearch = bingCustomSearch; + } + + /// Initializes a new instance of for deserialization. + internal RunStepCustomSearchToolCall() + { + } + + /// Reserved for future use. + public IReadOnlyDictionary BingCustomSearch { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDelta.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDelta.Serialization.cs new file mode 100644 index 000000000000..700b63e59825 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDelta.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDelta : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDelta)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(StepDetails)) + { + writer.WritePropertyName("step_details"u8); + writer.WriteObjectValue(StepDetails, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDelta)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDelta(document.RootElement, options); + } + + internal static RunStepDelta DeserializeRunStepDelta(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepDeltaDetail stepDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("step_details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stepDetails = RunStepDeltaDetail.DeserializeRunStepDeltaDetail(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDelta(stepDetails, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDelta)} does not support writing '{options.Format}' format."); + } + } + + RunStepDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDelta)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDelta FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDelta(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDelta.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDelta.cs new file mode 100644 index 000000000000..3e9c46546c95 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDelta.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the delta payload in a streaming run step delta chunk. + public partial class RunStepDelta + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RunStepDelta() + { + } + + /// Initializes a new instance of . + /// + /// The details of the run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal RunStepDelta(RunStepDeltaDetail stepDetails, IDictionary serializedAdditionalRawData) + { + StepDetails = stepDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The details of the run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public RunStepDeltaDetail StepDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunk.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunk.Serialization.cs new file mode 100644 index 000000000000..b6a41b462791 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunk.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaChunk : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaChunk)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("delta"u8); + writer.WriteObjectValue(Delta, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepDeltaChunk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaChunk)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaChunk(document.RootElement, options); + } + + internal static RunStepDeltaChunk DeserializeRunStepDeltaChunk(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + RunStepDeltaChunkObject @object = default; + RunStepDelta delta = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new RunStepDeltaChunkObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("delta"u8)) + { + delta = RunStepDelta.DeserializeRunStepDelta(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaChunk(id, @object, delta, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaChunk)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaChunk IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaChunk(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaChunk)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaChunk FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaChunk(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunk.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunk.cs new file mode 100644 index 000000000000..c2c59e01d709 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunk.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a run step delta i.e. any changed fields on a run step during streaming. + public partial class RunStepDeltaChunk + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier of the run step, which can be referenced in API endpoints. + /// The delta containing the fields that have changed on the run step. + /// or is null. + internal RunStepDeltaChunk(string id, RunStepDelta delta) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(delta, nameof(delta)); + + Id = id; + Delta = delta; + } + + /// Initializes a new instance of . + /// The identifier of the run step, which can be referenced in API endpoints. + /// The object type, which is always `thread.run.step.delta`. + /// The delta containing the fields that have changed on the run step. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaChunk(string id, RunStepDeltaChunkObject @object, RunStepDelta delta, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + Delta = delta; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaChunk() + { + } + + /// The identifier of the run step, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always `thread.run.step.delta`. + public RunStepDeltaChunkObject Object { get; } = RunStepDeltaChunkObject.ThreadRunStepDelta; + + /// The delta containing the fields that have changed on the run step. + public RunStepDelta Delta { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunkObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunkObject.cs new file mode 100644 index 000000000000..c3606cdd1a89 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaChunkObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The RunStepDeltaChunk_object. + public readonly partial struct RunStepDeltaChunkObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStepDeltaChunkObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; + + /// thread.run.step.delta. + public static RunStepDeltaChunkObject ThreadRunStepDelta { get; } = new RunStepDeltaChunkObject(ThreadRunStepDeltaValue); + /// Determines if two values are the same. + public static bool operator ==(RunStepDeltaChunkObject left, RunStepDeltaChunkObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStepDeltaChunkObject left, RunStepDeltaChunkObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RunStepDeltaChunkObject(string value) => new RunStepDeltaChunkObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepDeltaChunkObject other && Equals(other); + /// + public bool Equals(RunStepDeltaChunkObject 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.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs new file mode 100644 index 000000000000..2e6490ebf7e5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaCodeInterpreterDetailItemObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterDetailItemObject)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Input)) + { + writer.WritePropertyName("input"u8); + writer.WriteStringValue(Input); + } + if (Optional.IsCollectionDefined(Outputs)) + { + writer.WritePropertyName("outputs"u8); + writer.WriteStartArray(); + foreach (var item in Outputs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepDeltaCodeInterpreterDetailItemObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterDetailItemObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterDetailItemObject(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterDetailItemObject DeserializeRunStepDeltaCodeInterpreterDetailItemObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string input = default; + IReadOnlyList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("input"u8)) + { + input = property.Value.GetString(); + continue; + } + if (property.NameEquals("outputs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RunStepDeltaCodeInterpreterOutput.DeserializeRunStepDeltaCodeInterpreterOutput(item, options)); + } + outputs = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaCodeInterpreterDetailItemObject(input, outputs ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterDetailItemObject)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterDetailItemObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterDetailItemObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterDetailItemObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaCodeInterpreterDetailItemObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterDetailItemObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.cs new file mode 100644 index 000000000000..192f977c9a14 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the Code Interpreter tool call data in a streaming run step's tool calls. + public partial class RunStepDeltaCodeInterpreterDetailItemObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RunStepDeltaCodeInterpreterDetailItemObject() + { + Outputs = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The input into the Code Interpreter tool call. + /// + /// The outputs from the Code Interpreter tool call. Code Interpreter can output one or more + /// items, including text (`logs`) or images (`image`). Each of these are represented by a + /// different object type. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaCodeInterpreterDetailItemObject(string input, IReadOnlyList outputs, IDictionary serializedAdditionalRawData) + { + Input = input; + Outputs = outputs; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The input into the Code Interpreter tool call. + public string Input { get; } + /// + /// The outputs from the Code Interpreter tool call. Code Interpreter can output one or more + /// items, including text (`logs`) or images (`image`). Each of these are represented by a + /// different object type. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public IReadOnlyList Outputs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs new file mode 100644 index 000000000000..9ffc7b218f8d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaCodeInterpreterImageOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutput)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Image)) + { + writer.WritePropertyName("image"u8); + writer.WriteObjectValue(Image, options); + } + } + + RunStepDeltaCodeInterpreterImageOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterImageOutput(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterImageOutput DeserializeRunStepDeltaCodeInterpreterImageOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepDeltaCodeInterpreterImageOutputObject image = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + image = RunStepDeltaCodeInterpreterImageOutputObject.DeserializeRunStepDeltaCodeInterpreterImageOutputObject(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaCodeInterpreterImageOutput(index, type, serializedAdditionalRawData, image); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterImageOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterImageOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaCodeInterpreterImageOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterImageOutput(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutput.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutput.cs new file mode 100644 index 000000000000..0191dc63dbfe --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutput.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents an image output as produced the Code interpreter tool and as represented in a streaming run step's delta tool calls collection. + public partial class RunStepDeltaCodeInterpreterImageOutput : RunStepDeltaCodeInterpreterOutput + { + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + internal RunStepDeltaCodeInterpreterImageOutput(int index) : base(index) + { + Type = "image"; + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The type of the streaming run step tool call's Code Interpreter output. + /// Keeps track of any properties unknown to the library. + /// The image data for the Code Interpreter tool call output. + internal RunStepDeltaCodeInterpreterImageOutput(int index, string type, IDictionary serializedAdditionalRawData, RunStepDeltaCodeInterpreterImageOutputObject image) : base(index, type, serializedAdditionalRawData) + { + Image = image; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaCodeInterpreterImageOutput() + { + } + + /// The image data for the Code Interpreter tool call output. + public RunStepDeltaCodeInterpreterImageOutputObject Image { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs new file mode 100644 index 000000000000..bc6b5b8aed67 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaCodeInterpreterImageOutputObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutputObject)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepDeltaCodeInterpreterImageOutputObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutputObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterImageOutputObject(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterImageOutputObject DeserializeRunStepDeltaCodeInterpreterImageOutputObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaCodeInterpreterImageOutputObject(fileId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutputObject)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterImageOutputObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterImageOutputObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutputObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaCodeInterpreterImageOutputObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterImageOutputObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.cs new file mode 100644 index 000000000000..44a8b7f34321 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the data for a streaming run step's Code Interpreter tool call image output. + public partial class RunStepDeltaCodeInterpreterImageOutputObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RunStepDeltaCodeInterpreterImageOutputObject() + { + } + + /// Initializes a new instance of . + /// The file ID for the image. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaCodeInterpreterImageOutputObject(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The file ID for the image. + public string FileId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs new file mode 100644 index 000000000000..c617f4eb9b3e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaCodeInterpreterLogOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterLogOutput)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Logs)) + { + writer.WritePropertyName("logs"u8); + writer.WriteStringValue(Logs); + } + } + + RunStepDeltaCodeInterpreterLogOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterLogOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterLogOutput(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterLogOutput DeserializeRunStepDeltaCodeInterpreterLogOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string logs = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("logs"u8)) + { + logs = property.Value.GetString(); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaCodeInterpreterLogOutput(index, type, serializedAdditionalRawData, logs); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterLogOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterLogOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterLogOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterLogOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaCodeInterpreterLogOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterLogOutput(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterLogOutput.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterLogOutput.cs new file mode 100644 index 000000000000..1c950bf4292d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterLogOutput.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a log output as produced by the Code Interpreter tool and as represented in a streaming run step's delta tool calls collection. + public partial class RunStepDeltaCodeInterpreterLogOutput : RunStepDeltaCodeInterpreterOutput + { + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + internal RunStepDeltaCodeInterpreterLogOutput(int index) : base(index) + { + Type = "logs"; + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The type of the streaming run step tool call's Code Interpreter output. + /// Keeps track of any properties unknown to the library. + /// The text output from the Code Interpreter tool call. + internal RunStepDeltaCodeInterpreterLogOutput(int index, string type, IDictionary serializedAdditionalRawData, string logs) : base(index, type, serializedAdditionalRawData) + { + Logs = logs; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaCodeInterpreterLogOutput() + { + } + + /// The text output from the Code Interpreter tool call. + public string Logs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs new file mode 100644 index 000000000000..61614361912a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs @@ -0,0 +1,136 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownRunStepDeltaCodeInterpreterOutput))] + public partial class RunStepDeltaCodeInterpreterOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepDeltaCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterOutput DeserializeRunStepDeltaCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "image": return RunStepDeltaCodeInterpreterImageOutput.DeserializeRunStepDeltaCodeInterpreterImageOutput(element, options); + case "logs": return RunStepDeltaCodeInterpreterLogOutput.DeserializeRunStepDeltaCodeInterpreterLogOutput(element, options); + } + } + return UnknownRunStepDeltaCodeInterpreterOutput.DeserializeUnknownRunStepDeltaCodeInterpreterOutput(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaCodeInterpreterOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterOutput.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterOutput.cs new file mode 100644 index 000000000000..fc93b091f55c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterOutput.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// The abstract base representation of a streaming run step tool call's Code Interpreter tool output. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class RunStepDeltaCodeInterpreterOutput + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + protected RunStepDeltaCodeInterpreterOutput(int index) + { + Index = index; + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The type of the streaming run step tool call's Code Interpreter output. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaCodeInterpreterOutput(int index, string type, IDictionary serializedAdditionalRawData) + { + Index = index; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaCodeInterpreterOutput() + { + } + + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + public int Index { get; } + /// The type of the streaming run step tool call's Code Interpreter output. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs new file mode 100644 index 000000000000..b112741718ed --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaCodeInterpreterToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + } + + RunStepDeltaCodeInterpreterToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterToolCall(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterToolCall DeserializeRunStepDeltaCodeInterpreterToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter = default; + int index = default; + string id = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + codeInterpreter = RunStepDeltaCodeInterpreterDetailItemObject.DeserializeRunStepDeltaCodeInterpreterDetailItemObject(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaCodeInterpreterToolCall(index, id, type, serializedAdditionalRawData, codeInterpreter); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaCodeInterpreterToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterToolCall.cs new file mode 100644 index 000000000000..abece695d24c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaCodeInterpreterToolCall.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a Code Interpreter tool call within a streaming run step's tool call details. + public partial class RunStepDeltaCodeInterpreterToolCall : RunStepDeltaToolCall + { + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// is null. + internal RunStepDeltaCodeInterpreterToolCall(int index, string id) : base(index, id) + { + Argument.AssertNotNull(id, nameof(id)); + + Type = "code_interpreter"; + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// Keeps track of any properties unknown to the library. + /// The Code Interpreter data for the tool call. + internal RunStepDeltaCodeInterpreterToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData, RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter) : base(index, id, type, serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaCodeInterpreterToolCall() + { + } + + /// The Code Interpreter data for the tool call. + public RunStepDeltaCodeInterpreterDetailItemObject CodeInterpreter { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaDetail.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaDetail.Serialization.cs new file mode 100644 index 000000000000..3c4a8b606ed1 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaDetail.Serialization.cs @@ -0,0 +1,134 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownRunStepDeltaDetail))] + public partial class RunStepDeltaDetail : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepDeltaDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaDetail(document.RootElement, options); + } + + internal static RunStepDeltaDetail DeserializeRunStepDeltaDetail(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "message_creation": return RunStepDeltaMessageCreation.DeserializeRunStepDeltaMessageCreation(element, options); + case "tool_calls": return RunStepDeltaToolCallObject.DeserializeRunStepDeltaToolCallObject(element, options); + } + } + return UnknownRunStepDeltaDetail.DeserializeUnknownRunStepDeltaDetail(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaDetail(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaDetail FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaDetail(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaDetail.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaDetail.cs new file mode 100644 index 000000000000..ba64eb14a8f8 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaDetail.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// Represents a single run step detail item in a streaming run step's delta payload. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class RunStepDeltaDetail + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected RunStepDeltaDetail() + { + } + + /// Initializes a new instance of . + /// The object type for the run step detail object. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaDetail(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type for the run step detail object. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs new file mode 100644 index 000000000000..2cecc7416c67 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaFileSearchToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFileSearchToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + } + + RunStepDeltaFileSearchToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFileSearchToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaFileSearchToolCall(document.RootElement, options); + } + + internal static RunStepDeltaFileSearchToolCall DeserializeRunStepDeltaFileSearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepFileSearchToolCallResults fileSearch = default; + int index = default; + string id = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileSearch = RunStepFileSearchToolCallResults.DeserializeRunStepFileSearchToolCallResults(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaFileSearchToolCall(index, id, type, serializedAdditionalRawData, fileSearch); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaFileSearchToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaFileSearchToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaFileSearchToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaFileSearchToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaFileSearchToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaFileSearchToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFileSearchToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFileSearchToolCall.cs new file mode 100644 index 000000000000..f5550774c77e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFileSearchToolCall.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a file search tool call within a streaming run step's tool call details. + public partial class RunStepDeltaFileSearchToolCall : RunStepDeltaToolCall + { + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// is null. + internal RunStepDeltaFileSearchToolCall(int index, string id) : base(index, id) + { + Argument.AssertNotNull(id, nameof(id)); + + Type = "file_search"; + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepDeltaFileSearchToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData, RunStepFileSearchToolCallResults fileSearch) : base(index, id, type, serializedAdditionalRawData) + { + FileSearch = fileSearch; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaFileSearchToolCall() + { + } + + /// Reserved for future use. + public RunStepFileSearchToolCallResults FileSearch { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunction.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunction.Serialization.cs new file mode 100644 index 000000000000..826153fe839d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunction.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaFunction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Arguments)) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + if (Optional.IsDefined(Output)) + { + if (Output != null) + { + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + else + { + writer.WriteNull("output"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepDeltaFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaFunction(document.RootElement, options); + } + + internal static RunStepDeltaFunction DeserializeRunStepDeltaFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + string output = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("arguments"u8)) + { + arguments = property.Value.GetString(); + continue; + } + if (property.NameEquals("output"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + output = null; + continue; + } + output = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaFunction(name, arguments, output, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaFunction FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaFunction(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunction.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunction.cs new file mode 100644 index 000000000000..5a663072e65b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunction.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the function data in a streaming run step delta's function tool call. + public partial class RunStepDeltaFunction + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RunStepDeltaFunction() + { + } + + /// Initializes a new instance of . + /// The name of the function. + /// The arguments passed to the function as input. + /// The output of the function, null if outputs have not yet been submitted. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaFunction(string name, string arguments, string output, IDictionary serializedAdditionalRawData) + { + Name = name; + Arguments = arguments; + Output = output; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name of the function. + public string Name { get; } + /// The arguments passed to the function as input. + public string Arguments { get; } + /// The output of the function, null if outputs have not yet been submitted. + public string Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs new file mode 100644 index 000000000000..fde2c529e074 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaFunctionToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFunctionToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Function)) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + } + } + + RunStepDeltaFunctionToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFunctionToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaFunctionToolCall(document.RootElement, options); + } + + internal static RunStepDeltaFunctionToolCall DeserializeRunStepDeltaFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepDeltaFunction function = default; + int index = default; + string id = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("function"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + function = RunStepDeltaFunction.DeserializeRunStepDeltaFunction(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaFunctionToolCall(index, id, type, serializedAdditionalRawData, function); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaFunctionToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaFunctionToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaFunctionToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaFunctionToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaFunctionToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaFunctionToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunctionToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunctionToolCall.cs new file mode 100644 index 000000000000..2214f37dea45 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaFunctionToolCall.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a function tool call within a streaming run step's tool call details. + public partial class RunStepDeltaFunctionToolCall : RunStepDeltaToolCall + { + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// is null. + internal RunStepDeltaFunctionToolCall(int index, string id) : base(index, id) + { + Argument.AssertNotNull(id, nameof(id)); + + Type = "function"; + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// Keeps track of any properties unknown to the library. + /// The function data for the tool call. + internal RunStepDeltaFunctionToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData, RunStepDeltaFunction function) : base(index, id, type, serializedAdditionalRawData) + { + Function = function; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaFunctionToolCall() + { + } + + /// The function data for the tool call. + public RunStepDeltaFunction Function { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreation.Serialization.cs new file mode 100644 index 000000000000..b6fc500e5665 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreation.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaMessageCreation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreation)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(MessageCreation)) + { + writer.WritePropertyName("message_creation"u8); + writer.WriteObjectValue(MessageCreation, options); + } + } + + RunStepDeltaMessageCreation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaMessageCreation(document.RootElement, options); + } + + internal static RunStepDeltaMessageCreation DeserializeRunStepDeltaMessageCreation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepDeltaMessageCreationObject messageCreation = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message_creation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + messageCreation = RunStepDeltaMessageCreationObject.DeserializeRunStepDeltaMessageCreationObject(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaMessageCreation(type, serializedAdditionalRawData, messageCreation); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreation)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaMessageCreation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaMessageCreation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaMessageCreation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaMessageCreation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreation.cs new file mode 100644 index 000000000000..68fc787dcd16 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreation.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents a message creation within a streaming run step delta. + public partial class RunStepDeltaMessageCreation : RunStepDeltaDetail + { + /// Initializes a new instance of . + internal RunStepDeltaMessageCreation() + { + Type = "message_creation"; + } + + /// Initializes a new instance of . + /// The object type for the run step detail object. + /// Keeps track of any properties unknown to the library. + /// The message creation data. + internal RunStepDeltaMessageCreation(string type, IDictionary serializedAdditionalRawData, RunStepDeltaMessageCreationObject messageCreation) : base(type, serializedAdditionalRawData) + { + MessageCreation = messageCreation; + } + + /// The message creation data. + public RunStepDeltaMessageCreationObject MessageCreation { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs new file mode 100644 index 000000000000..3844cfeba517 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaMessageCreationObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreationObject)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(MessageId)) + { + writer.WritePropertyName("message_id"u8); + writer.WriteStringValue(MessageId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepDeltaMessageCreationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreationObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaMessageCreationObject(document.RootElement, options); + } + + internal static RunStepDeltaMessageCreationObject DeserializeRunStepDeltaMessageCreationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string messageId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message_id"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaMessageCreationObject(messageId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreationObject)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaMessageCreationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaMessageCreationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreationObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaMessageCreationObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaMessageCreationObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreationObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreationObject.cs new file mode 100644 index 000000000000..54580925ec03 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaMessageCreationObject.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents the data within a streaming run step message creation response object. + public partial class RunStepDeltaMessageCreationObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RunStepDeltaMessageCreationObject() + { + } + + /// Initializes a new instance of . + /// The ID of the newly-created message. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaMessageCreationObject(string messageId, IDictionary serializedAdditionalRawData) + { + MessageId = messageId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The ID of the newly-created message. + public string MessageId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCall.Serialization.cs new file mode 100644 index 000000000000..5b8839b95507 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCall.Serialization.cs @@ -0,0 +1,139 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownRunStepDeltaToolCall))] + public partial class RunStepDeltaToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepDeltaToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaToolCall(document.RootElement, options); + } + + internal static RunStepDeltaToolCall DeserializeRunStepDeltaToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "code_interpreter": return RunStepDeltaCodeInterpreterToolCall.DeserializeRunStepDeltaCodeInterpreterToolCall(element, options); + case "file_search": return RunStepDeltaFileSearchToolCall.DeserializeRunStepDeltaFileSearchToolCall(element, options); + case "function": return RunStepDeltaFunctionToolCall.DeserializeRunStepDeltaFunctionToolCall(element, options); + } + } + return UnknownRunStepDeltaToolCall.DeserializeUnknownRunStepDeltaToolCall(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaToolCall(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCall.cs new file mode 100644 index 000000000000..2feece139572 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCall.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// The abstract base representation of a single tool call within a streaming run step's delta tool call details. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class RunStepDeltaToolCall + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// is null. + protected RunStepDeltaToolCall(int index, string id) + { + Argument.AssertNotNull(id, nameof(id)); + + Index = index; + Id = id; + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData) + { + Index = index; + Id = id; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaToolCall() + { + } + + /// The index of the tool call detail in the run step's tool_calls array. + public int Index { get; } + /// The ID of the tool call, used when submitting outputs to the run. + public string Id { get; } + /// The type of the tool call detail item in a streaming run step's details. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCallObject.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCallObject.Serialization.cs new file mode 100644 index 000000000000..0a223ddead28 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCallObject.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepDeltaToolCallObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCallObject)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(ToolCalls)) + { + writer.WritePropertyName("tool_calls"u8); + writer.WriteStartArray(); + foreach (var item in ToolCalls) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + RunStepDeltaToolCallObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCallObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaToolCallObject(document.RootElement, options); + } + + internal static RunStepDeltaToolCallObject DeserializeRunStepDeltaToolCallObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList toolCalls = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RunStepDeltaToolCall.DeserializeRunStepDeltaToolCall(item, options)); + } + toolCalls = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaToolCallObject(type, serializedAdditionalRawData, toolCalls ?? new ChangeTrackingList()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCallObject)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaToolCallObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaToolCallObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCallObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaToolCallObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaToolCallObject(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCallObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCallObject.cs new file mode 100644 index 000000000000..a62a3ae85d35 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDeltaToolCallObject.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Represents an invocation of tool calls as part of a streaming run step. + public partial class RunStepDeltaToolCallObject : RunStepDeltaDetail + { + /// Initializes a new instance of . + internal RunStepDeltaToolCallObject() + { + Type = "tool_calls"; + ToolCalls = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The object type for the run step detail object. + /// Keeps track of any properties unknown to the library. + /// + /// The collection of tool calls for the tool call detail item. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + internal RunStepDeltaToolCallObject(string type, IDictionary serializedAdditionalRawData, IReadOnlyList toolCalls) : base(type, serializedAdditionalRawData) + { + ToolCalls = toolCalls; + } + + /// + /// The collection of tool calls for the tool call detail item. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public IReadOnlyList ToolCalls { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDetails.Serialization.cs new file mode 100644 index 000000000000..6b6c3f77b345 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDetails.Serialization.cs @@ -0,0 +1,134 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownRunStepDetails))] + public partial class RunStepDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDetails(document.RootElement, options); + } + + internal static RunStepDetails DeserializeRunStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "message_creation": return RunStepMessageCreationDetails.DeserializeRunStepMessageCreationDetails(element, options); + case "tool_calls": return RunStepToolCallDetails.DeserializeRunStepToolCallDetails(element, options); + } + } + return UnknownRunStepDetails.DeserializeUnknownRunStepDetails(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{options.Format}' format."); + } + } + + RunStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDetails.cs new file mode 100644 index 000000000000..cf2a6d05625a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepDetails.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An abstract representation of the details for a run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class RunStepDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected RunStepDetails() + { + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal RunStepDetails(RunStepType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type. + internal RunStepType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepError.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepError.Serialization.cs new file mode 100644 index 000000000000..02623bf20651 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepError.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepError)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code.ToString()); + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepError)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepError(document.RootElement, options); + } + + internal static RunStepError DeserializeRunStepError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepErrorCode code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = new RunStepErrorCode(property.Value.GetString()); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepError(code, message, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepError)} does not support writing '{options.Format}' format."); + } + } + + RunStepError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepError)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepError FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepError(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepError.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepError.cs new file mode 100644 index 000000000000..83eec6ff7e14 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepError.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The error information associated with a failed run step. + public partial class RunStepError + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The error code for this error. + /// The human-readable text associated with this error. + /// is null. + internal RunStepError(RunStepErrorCode code, string message) + { + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + } + + /// Initializes a new instance of . + /// The error code for this error. + /// The human-readable text associated with this error. + /// Keeps track of any properties unknown to the library. + internal RunStepError(RunStepErrorCode code, string message, IDictionary serializedAdditionalRawData) + { + Code = code; + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepError() + { + } + + /// The error code for this error. + public RunStepErrorCode Code { get; } + /// The human-readable text associated with this error. + public string Message { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepErrorCode.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepErrorCode.cs new file mode 100644 index 000000000000..a880adc3e37d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepErrorCode.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Possible error code values attributable to a failed run step. + public readonly partial struct RunStepErrorCode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStepErrorCode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ServerErrorValue = "server_error"; + private const string RateLimitExceededValue = "rate_limit_exceeded"; + + /// Represents a server error. + public static RunStepErrorCode ServerError { get; } = new RunStepErrorCode(ServerErrorValue); + /// Represents an error indicating configured rate limits were exceeded. + public static RunStepErrorCode RateLimitExceeded { get; } = new RunStepErrorCode(RateLimitExceededValue); + /// Determines if two values are the same. + public static bool operator ==(RunStepErrorCode left, RunStepErrorCode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStepErrorCode left, RunStepErrorCode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RunStepErrorCode(string value) => new RunStepErrorCode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepErrorCode other && Equals(other); + /// + public bool Equals(RunStepErrorCode 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.Agents.Persistent/src/Generated/RunStepFileSearchToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCall.Serialization.cs new file mode 100644 index 000000000000..28d4addd98f1 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCall.Serialization.cs @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepFileSearchToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepFileSearchToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + + RunStepFileSearchToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepFileSearchToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepFileSearchToolCall(document.RootElement, options); + } + + internal static RunStepFileSearchToolCall DeserializeRunStepFileSearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepFileSearchToolCallResults fileSearch = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_search"u8)) + { + fileSearch = RunStepFileSearchToolCallResults.DeserializeRunStepFileSearchToolCallResults(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepFileSearchToolCall(type, id, serializedAdditionalRawData, fileSearch); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepFileSearchToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepFileSearchToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepFileSearchToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepFileSearchToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepFileSearchToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepFileSearchToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCall.cs new file mode 100644 index 000000000000..cb33e92e5819 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A record of a call to a file search tool, issued by the model in evaluation of a defined tool, that represents + /// executed file search. + /// + public partial class RunStepFileSearchToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// For now, this is always going to be an empty object. + /// or is null. + internal RunStepFileSearchToolCall(string id, RunStepFileSearchToolCallResults fileSearch) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(fileSearch, nameof(fileSearch)); + + Type = "file_search"; + FileSearch = fileSearch; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// For now, this is always going to be an empty object. + internal RunStepFileSearchToolCall(string type, string id, IDictionary serializedAdditionalRawData, RunStepFileSearchToolCallResults fileSearch) : base(type, id, serializedAdditionalRawData) + { + FileSearch = fileSearch; + } + + /// Initializes a new instance of for deserialization. + internal RunStepFileSearchToolCall() + { + } + + /// For now, this is always going to be an empty object. + public RunStepFileSearchToolCallResults FileSearch { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResult.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResult.Serialization.cs new file mode 100644 index 000000000000..b8353b9a9776 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResult.Serialization.cs @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepFileSearchToolCallResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + writer.WritePropertyName("file_name"u8); + writer.WriteStringValue(FileName); + writer.WritePropertyName("score"u8); + writer.WriteNumberValue(Score); + if (Optional.IsCollectionDefined(Content)) + { + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in Content) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepFileSearchToolCallResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepFileSearchToolCallResult(document.RootElement, options); + } + + internal static RunStepFileSearchToolCallResult DeserializeRunStepFileSearchToolCallResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string fileName = default; + float score = default; + IReadOnlyList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("file_name"u8)) + { + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("score"u8)) + { + score = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("content"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(FileSearchToolCallContent.DeserializeFileSearchToolCallContent(item, options)); + } + content = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepFileSearchToolCallResult(fileId, fileName, score, content ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResult)} does not support writing '{options.Format}' format."); + } + } + + RunStepFileSearchToolCallResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepFileSearchToolCallResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepFileSearchToolCallResult FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepFileSearchToolCallResult(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResult.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResult.cs new file mode 100644 index 000000000000..7333b5c12fff --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResult.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// File search tool call result. + public partial class RunStepFileSearchToolCallResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the file that result was found in. + /// The name of the file that result was found in. + /// The score of the result. All values must be a floating point number between 0 and 1. + /// or is null. + internal RunStepFileSearchToolCallResult(string fileId, string fileName, float score) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(fileName, nameof(fileName)); + + FileId = fileId; + FileName = fileName; + Score = score; + Content = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The ID of the file that result was found in. + /// The name of the file that result was found in. + /// The score of the result. All values must be a floating point number between 0 and 1. + /// The content of the result that was found. The content is only included if requested via the include query parameter. + /// Keeps track of any properties unknown to the library. + internal RunStepFileSearchToolCallResult(string fileId, string fileName, float score, IReadOnlyList content, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + FileName = fileName; + Score = score; + Content = content; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepFileSearchToolCallResult() + { + } + + /// The ID of the file that result was found in. + public string FileId { get; } + /// The name of the file that result was found in. + public string FileName { get; } + /// The score of the result. All values must be a floating point number between 0 and 1. + public float Score { get; } + /// The content of the result that was found. The content is only included if requested via the include query parameter. + public IReadOnlyList Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResults.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResults.Serialization.cs new file mode 100644 index 000000000000..89aef5d8064d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResults.Serialization.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepFileSearchToolCallResults : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResults)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(RankingOptions)) + { + writer.WritePropertyName("ranking_options"u8); + writer.WriteObjectValue(RankingOptions, options); + } + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepFileSearchToolCallResults IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResults)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepFileSearchToolCallResults(document.RootElement, options); + } + + internal static RunStepFileSearchToolCallResults DeserializeRunStepFileSearchToolCallResults(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + FileSearchRankingOptions rankingOptions = default; + IReadOnlyList results = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ranking_options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rankingOptions = FileSearchRankingOptions.DeserializeFileSearchRankingOptions(property.Value, options); + continue; + } + if (property.NameEquals("results"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RunStepFileSearchToolCallResult.DeserializeRunStepFileSearchToolCallResult(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepFileSearchToolCallResults(rankingOptions, results, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResults)} does not support writing '{options.Format}' format."); + } + } + + RunStepFileSearchToolCallResults IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepFileSearchToolCallResults(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepFileSearchToolCallResults)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepFileSearchToolCallResults FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepFileSearchToolCallResults(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResults.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResults.cs new file mode 100644 index 000000000000..6fdb9f200dcb --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFileSearchToolCallResults.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The results of the file search. + public partial class RunStepFileSearchToolCallResults + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The array of a file search results. + /// is null. + internal RunStepFileSearchToolCallResults(IEnumerable results) + { + Argument.AssertNotNull(results, nameof(results)); + + Results = results.ToList(); + } + + /// Initializes a new instance of . + /// Ranking options for file search. + /// The array of a file search results. + /// Keeps track of any properties unknown to the library. + internal RunStepFileSearchToolCallResults(FileSearchRankingOptions rankingOptions, IReadOnlyList results, IDictionary serializedAdditionalRawData) + { + RankingOptions = rankingOptions; + Results = results; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepFileSearchToolCallResults() + { + } + + /// Ranking options for file search. + public FileSearchRankingOptions RankingOptions { get; } + /// The array of a file search results. + public IReadOnlyList Results { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFunctionToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFunctionToolCall.Serialization.cs new file mode 100644 index 000000000000..44194e6c6706 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFunctionToolCall.Serialization.cs @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepFunctionToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepFunctionToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(InternalDetails, options); + } + + RunStepFunctionToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepFunctionToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepFunctionToolCall(document.RootElement, options); + } + + internal static RunStepFunctionToolCall DeserializeRunStepFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalRunStepFunctionToolCallDetails function = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("function"u8)) + { + function = InternalRunStepFunctionToolCallDetails.DeserializeInternalRunStepFunctionToolCallDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepFunctionToolCall(type, id, serializedAdditionalRawData, function); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepFunctionToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepFunctionToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepFunctionToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepFunctionToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepFunctionToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepFunctionToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFunctionToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFunctionToolCall.cs new file mode 100644 index 000000000000..efec0f8fe168 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepFunctionToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A record of a call to a function tool, issued by the model in evaluation of a defined tool, that represents the inputs + /// and output consumed and emitted by the specified function. + /// + public partial class RunStepFunctionToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// The detailed information about the function called by the model. + /// or is null. + internal RunStepFunctionToolCall(string id, InternalRunStepFunctionToolCallDetails internalDetails) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(internalDetails, nameof(internalDetails)); + + Type = "function"; + InternalDetails = internalDetails; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// The detailed information about the function called by the model. + internal RunStepFunctionToolCall(string type, string id, IDictionary serializedAdditionalRawData, InternalRunStepFunctionToolCallDetails internalDetails) : base(type, id, serializedAdditionalRawData) + { + InternalDetails = internalDetails; + } + + /// Initializes a new instance of for deserialization. + internal RunStepFunctionToolCall() + { + } + + /// The detailed information about the function called by the model. + public InternalRunStepFunctionToolCallDetails InternalDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationDetails.Serialization.cs new file mode 100644 index 000000000000..6f0eeefe27ea --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationDetails.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepMessageCreationDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepMessageCreationDetails)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("message_creation"u8); + writer.WriteObjectValue(MessageCreation, options); + } + + RunStepMessageCreationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepMessageCreationDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepMessageCreationDetails(document.RootElement, options); + } + + internal static RunStepMessageCreationDetails DeserializeRunStepMessageCreationDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepMessageCreationReference messageCreation = default; + RunStepType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message_creation"u8)) + { + messageCreation = RunStepMessageCreationReference.DeserializeRunStepMessageCreationReference(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new RunStepType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepMessageCreationDetails(type, serializedAdditionalRawData, messageCreation); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepMessageCreationDetails)} does not support writing '{options.Format}' format."); + } + } + + RunStepMessageCreationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepMessageCreationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepMessageCreationDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepMessageCreationDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepMessageCreationDetails(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationDetails.cs new file mode 100644 index 000000000000..c08aa7e44347 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationDetails.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The detailed information associated with a message creation run step. + public partial class RunStepMessageCreationDetails : RunStepDetails + { + /// Initializes a new instance of . + /// Information about the message creation associated with this run step. + /// is null. + internal RunStepMessageCreationDetails(RunStepMessageCreationReference messageCreation) + { + Argument.AssertNotNull(messageCreation, nameof(messageCreation)); + + Type = RunStepType.MessageCreation; + MessageCreation = messageCreation; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// Information about the message creation associated with this run step. + internal RunStepMessageCreationDetails(RunStepType type, IDictionary serializedAdditionalRawData, RunStepMessageCreationReference messageCreation) : base(type, serializedAdditionalRawData) + { + MessageCreation = messageCreation; + } + + /// Initializes a new instance of for deserialization. + internal RunStepMessageCreationDetails() + { + } + + /// Information about the message creation associated with this run step. + public RunStepMessageCreationReference MessageCreation { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationReference.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationReference.Serialization.cs new file mode 100644 index 000000000000..91ba11498873 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationReference.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepMessageCreationReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepMessageCreationReference)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("message_id"u8); + writer.WriteStringValue(MessageId); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepMessageCreationReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepMessageCreationReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepMessageCreationReference(document.RootElement, options); + } + + internal static RunStepMessageCreationReference DeserializeRunStepMessageCreationReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string messageId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message_id"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepMessageCreationReference(messageId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepMessageCreationReference)} does not support writing '{options.Format}' format."); + } + } + + RunStepMessageCreationReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepMessageCreationReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepMessageCreationReference)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepMessageCreationReference FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepMessageCreationReference(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationReference.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationReference.cs new file mode 100644 index 000000000000..6945a200f86a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMessageCreationReference.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The details of a message created as a part of a run step. + public partial class RunStepMessageCreationReference + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the message created by this run step. + /// is null. + internal RunStepMessageCreationReference(string messageId) + { + Argument.AssertNotNull(messageId, nameof(messageId)); + + MessageId = messageId; + } + + /// Initializes a new instance of . + /// The ID of the message created by this run step. + /// Keeps track of any properties unknown to the library. + internal RunStepMessageCreationReference(string messageId, IDictionary serializedAdditionalRawData) + { + MessageId = messageId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepMessageCreationReference() + { + } + + /// The ID of the message created by this run step. + public string MessageId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMicrosoftFabricToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMicrosoftFabricToolCall.Serialization.cs new file mode 100644 index 000000000000..c1600303daf2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMicrosoftFabricToolCall.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepMicrosoftFabricToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepMicrosoftFabricToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("fabric_dataagent"u8); + writer.WriteStartObject(); + foreach (var item in MicrosoftFabric) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + + RunStepMicrosoftFabricToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepMicrosoftFabricToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepMicrosoftFabricToolCall(document.RootElement, options); + } + + internal static RunStepMicrosoftFabricToolCall DeserializeRunStepMicrosoftFabricToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary fabricDataagent = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fabric_dataagent"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + fabricDataagent = dictionary; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepMicrosoftFabricToolCall(type, id, serializedAdditionalRawData, fabricDataagent); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepMicrosoftFabricToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepMicrosoftFabricToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepMicrosoftFabricToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepMicrosoftFabricToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepMicrosoftFabricToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepMicrosoftFabricToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMicrosoftFabricToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMicrosoftFabricToolCall.cs new file mode 100644 index 000000000000..a78260a4ae24 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepMicrosoftFabricToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A record of a call to a Microsoft Fabric tool, issued by the model in evaluation of a defined tool, that represents + /// executed Microsoft Fabric operations. + /// + public partial class RunStepMicrosoftFabricToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// or is null. + internal RunStepMicrosoftFabricToolCall(string id, IReadOnlyDictionary microsoftFabric) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(microsoftFabric, nameof(microsoftFabric)); + + Type = "fabric_dataagent"; + MicrosoftFabric = microsoftFabric; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepMicrosoftFabricToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary microsoftFabric) : base(type, id, serializedAdditionalRawData) + { + MicrosoftFabric = microsoftFabric; + } + + /// Initializes a new instance of for deserialization. + internal RunStepMicrosoftFabricToolCall() + { + } + + /// Reserved for future use. + public IReadOnlyDictionary MicrosoftFabric { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepObject.cs new file mode 100644 index 000000000000..049f5f6bb7c0 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The RunStep_object. + public readonly partial struct RunStepObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStepObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadRunStepValue = "thread.run.step"; + + /// thread.run.step. + public static RunStepObject ThreadRunStep { get; } = new RunStepObject(ThreadRunStepValue); + /// Determines if two values are the same. + public static bool operator ==(RunStepObject left, RunStepObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStepObject left, RunStepObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RunStepObject(string value) => new RunStepObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepObject other && Equals(other); + /// + public bool Equals(RunStepObject 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.Agents.Persistent/src/Generated/RunStepOpenAPIToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepOpenAPIToolCall.Serialization.cs new file mode 100644 index 000000000000..b1e75d635310 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepOpenAPIToolCall.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepOpenAPIToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepOpenAPIToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("openapi"u8); + writer.WriteStartObject(); + foreach (var item in OpenAPI) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + + RunStepOpenAPIToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepOpenAPIToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepOpenAPIToolCall(document.RootElement, options); + } + + internal static RunStepOpenAPIToolCall DeserializeRunStepOpenAPIToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary openapi = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("openapi"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + openapi = dictionary; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepOpenAPIToolCall(type, id, serializedAdditionalRawData, openapi); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepOpenAPIToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepOpenAPIToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepOpenAPIToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepOpenAPIToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepOpenAPIToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepOpenAPIToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepOpenAPIToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepOpenAPIToolCall.cs new file mode 100644 index 000000000000..5405b48c0941 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepOpenAPIToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A record of a call to an OpenAPI tool, issued by the model in evaluation of a defined tool, that represents + /// executed OpenAPI operations. + /// + public partial class RunStepOpenAPIToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// or is null. + internal RunStepOpenAPIToolCall(string id, IReadOnlyDictionary openAPI) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(openAPI, nameof(openAPI)); + + Type = "openapi"; + OpenAPI = openAPI; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepOpenAPIToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary openAPI) : base(type, id, serializedAdditionalRawData) + { + OpenAPI = openAPI; + } + + /// Initializes a new instance of for deserialization. + internal RunStepOpenAPIToolCall() + { + } + + /// Reserved for future use. + public IReadOnlyDictionary OpenAPI { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepSharepointToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepSharepointToolCall.Serialization.cs new file mode 100644 index 000000000000..4b40dbe63d21 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepSharepointToolCall.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepSharepointToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepSharepointToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("sharepoint_grounding"u8); + writer.WriteStartObject(); + foreach (var item in SharePoint) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + + RunStepSharepointToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepSharepointToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepSharepointToolCall(document.RootElement, options); + } + + internal static RunStepSharepointToolCall DeserializeRunStepSharepointToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary sharepointGrounding = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sharepoint_grounding"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + sharepointGrounding = dictionary; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepSharepointToolCall(type, id, serializedAdditionalRawData, sharepointGrounding); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepSharepointToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepSharepointToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepSharepointToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepSharepointToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepSharepointToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepSharepointToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepSharepointToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepSharepointToolCall.cs new file mode 100644 index 000000000000..43a2c6932b4b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepSharepointToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A record of a call to a SharePoint tool, issued by the model in evaluation of a defined tool, that represents + /// executed SharePoint actions. + /// + public partial class RunStepSharepointToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// or is null. + internal RunStepSharepointToolCall(string id, IReadOnlyDictionary sharePoint) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(sharePoint, nameof(sharePoint)); + + Type = "sharepoint_grounding"; + SharePoint = sharePoint; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepSharepointToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary sharePoint) : base(type, id, serializedAdditionalRawData) + { + SharePoint = sharePoint; + } + + /// Initializes a new instance of for deserialization. + internal RunStepSharepointToolCall() + { + } + + /// Reserved for future use. + public IReadOnlyDictionary SharePoint { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepStatus.cs new file mode 100644 index 000000000000..e6402c19762a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepStatus.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Possible values for the status of a run step. + public readonly partial struct RunStepStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStepStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "in_progress"; + private const string CancelledValue = "cancelled"; + private const string FailedValue = "failed"; + private const string CompletedValue = "completed"; + private const string ExpiredValue = "expired"; + + /// Represents a run step still in progress. + public static RunStepStatus InProgress { get; } = new RunStepStatus(InProgressValue); + /// Represents a run step that was cancelled. + public static RunStepStatus Cancelled { get; } = new RunStepStatus(CancelledValue); + /// Represents a run step that failed. + public static RunStepStatus Failed { get; } = new RunStepStatus(FailedValue); + /// Represents a run step that successfully completed. + public static RunStepStatus Completed { get; } = new RunStepStatus(CompletedValue); + /// Represents a run step that expired before otherwise finishing. + public static RunStepStatus Expired { get; } = new RunStepStatus(ExpiredValue); + /// Determines if two values are the same. + public static bool operator ==(RunStepStatus left, RunStepStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStepStatus left, RunStepStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RunStepStatus(string value) => new RunStepStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepStatus other && Equals(other); + /// + public bool Equals(RunStepStatus 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.Agents.Persistent/src/Generated/RunStepStreamEvent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepStreamEvent.cs new file mode 100644 index 000000000000..075c49cc616f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepStreamEvent.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Run step operation related streaming events. + public readonly partial struct RunStepStreamEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStepStreamEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadRunStepCreatedValue = "thread.run.step.created"; + private const string ThreadRunStepInProgressValue = "thread.run.step.in_progress"; + private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; + private const string ThreadRunStepCompletedValue = "thread.run.step.completed"; + private const string ThreadRunStepFailedValue = "thread.run.step.failed"; + private const string ThreadRunStepCancelledValue = "thread.run.step.cancelled"; + private const string ThreadRunStepExpiredValue = "thread.run.step.expired"; + + /// Event sent when a new thread run step is created. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepCreated { get; } = new RunStepStreamEvent(ThreadRunStepCreatedValue); + /// Event sent when a run step moves to `in_progress` status. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepInProgress { get; } = new RunStepStreamEvent(ThreadRunStepInProgressValue); + /// Event sent when a run step is being streamed. The data of this event is of type RunStepDeltaChunk. + public static RunStepStreamEvent ThreadRunStepDelta { get; } = new RunStepStreamEvent(ThreadRunStepDeltaValue); + /// Event sent when a run step is completed. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepCompleted { get; } = new RunStepStreamEvent(ThreadRunStepCompletedValue); + /// Event sent when a run step fails. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepFailed { get; } = new RunStepStreamEvent(ThreadRunStepFailedValue); + /// Event sent when a run step is cancelled. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepCancelled { get; } = new RunStepStreamEvent(ThreadRunStepCancelledValue); + /// Event sent when a run step is expired. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepExpired { get; } = new RunStepStreamEvent(ThreadRunStepExpiredValue); + /// Determines if two values are the same. + public static bool operator ==(RunStepStreamEvent left, RunStepStreamEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStepStreamEvent left, RunStepStreamEvent right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RunStepStreamEvent(string value) => new RunStepStreamEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepStreamEvent other && Equals(other); + /// + public bool Equals(RunStepStreamEvent 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.Agents.Persistent/src/Generated/RunStepToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCall.Serialization.cs new file mode 100644 index 000000000000..8d9386e09e71 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCall.Serialization.cs @@ -0,0 +1,143 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownRunStepToolCall))] + public partial class RunStepToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RunStepToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepToolCall(document.RootElement, options); + } + + internal static RunStepToolCall DeserializeRunStepToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "azure_ai_search": return RunStepAzureAISearchToolCall.DeserializeRunStepAzureAISearchToolCall(element, options); + case "bing_custom_search": return RunStepCustomSearchToolCall.DeserializeRunStepCustomSearchToolCall(element, options); + case "bing_grounding": return RunStepBingGroundingToolCall.DeserializeRunStepBingGroundingToolCall(element, options); + case "code_interpreter": return RunStepCodeInterpreterToolCall.DeserializeRunStepCodeInterpreterToolCall(element, options); + case "fabric_dataagent": return RunStepMicrosoftFabricToolCall.DeserializeRunStepMicrosoftFabricToolCall(element, options); + case "file_search": return RunStepFileSearchToolCall.DeserializeRunStepFileSearchToolCall(element, options); + case "function": return RunStepFunctionToolCall.DeserializeRunStepFunctionToolCall(element, options); + case "openapi": return RunStepOpenAPIToolCall.DeserializeRunStepOpenAPIToolCall(element, options); + case "sharepoint_grounding": return RunStepSharepointToolCall.DeserializeRunStepSharepointToolCall(element, options); + } + } + return UnknownRunStepToolCall.DeserializeUnknownRunStepToolCall(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepToolCall(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCall.cs new file mode 100644 index 000000000000..e49c257df13c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCall.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An abstract representation of a detailed tool call as recorded within a run step for an existing run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + public abstract partial class RunStepToolCall + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// is null. + protected RunStepToolCall(string id) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + internal RunStepToolCall(string type, string id, IDictionary serializedAdditionalRawData) + { + Type = type; + Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepToolCall() + { + } + + /// The object type. + internal string Type { get; set; } + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + public string Id { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCallDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCallDetails.Serialization.cs new file mode 100644 index 000000000000..7bca20d0eecf --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCallDetails.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class RunStepToolCallDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepToolCallDetails)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("tool_calls"u8); + writer.WriteStartArray(); + foreach (var item in ToolCalls) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + RunStepToolCallDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepToolCallDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepToolCallDetails(document.RootElement, options); + } + + internal static RunStepToolCallDetails DeserializeRunStepToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList toolCalls = default; + RunStepType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_calls"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RunStepToolCall.DeserializeRunStepToolCall(item, options)); + } + toolCalls = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = new RunStepType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepToolCallDetails(type, serializedAdditionalRawData, toolCalls); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepToolCallDetails)} does not support writing '{options.Format}' format."); + } + } + + RunStepToolCallDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepToolCallDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepToolCallDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepToolCallDetails(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCallDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCallDetails.cs new file mode 100644 index 000000000000..e72d6fca171c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepToolCallDetails.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The detailed information associated with a run step calling tools. + public partial class RunStepToolCallDetails : RunStepDetails + { + /// Initializes a new instance of . + /// + /// A list of tool call details for this run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + /// is null. + internal RunStepToolCallDetails(IEnumerable toolCalls) + { + Argument.AssertNotNull(toolCalls, nameof(toolCalls)); + + Type = RunStepType.ToolCalls; + ToolCalls = toolCalls.ToList(); + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// + /// A list of tool call details for this run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + internal RunStepToolCallDetails(RunStepType type, IDictionary serializedAdditionalRawData, IReadOnlyList toolCalls) : base(type, serializedAdditionalRawData) + { + ToolCalls = toolCalls; + } + + /// Initializes a new instance of for deserialization. + internal RunStepToolCallDetails() + { + } + + /// + /// A list of tool call details for this run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , and . + /// + public IReadOnlyList ToolCalls { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepType.cs new file mode 100644 index 000000000000..fc8be57ed6d3 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStepType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The possible types of run steps. + public readonly partial struct RunStepType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStepType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string MessageCreationValue = "message_creation"; + private const string ToolCallsValue = "tool_calls"; + + /// Represents a run step to create a message. + public static RunStepType MessageCreation { get; } = new RunStepType(MessageCreationValue); + /// Represents a run step that calls tools. + public static RunStepType ToolCalls { get; } = new RunStepType(ToolCallsValue); + /// Determines if two values are the same. + public static bool operator ==(RunStepType left, RunStepType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStepType left, RunStepType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RunStepType(string value) => new RunStepType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepType other && Equals(other); + /// + public bool Equals(RunStepType 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.Agents.Persistent/src/Generated/RunSteps.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunSteps.cs new file mode 100644 index 000000000000..8318074de20e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunSteps.cs @@ -0,0 +1,420 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Agents.Persistent +{ + // Data plane generated sub-client. + /// + /// A collection of run‐step operations under + /// `/threads/{threadId}/runs/{runId}/steps`. + /// + public partial class RunSteps + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of RunSteps for mocking. + protected RunSteps() + { + } + + /// Initializes a new instance of RunSteps. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal RunSteps(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Retrieves a single run step from a thread run. + /// Identifier of the thread. + /// Identifier of the run. + /// Identifier of the run step. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + /// + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public virtual async Task> GetRunStepAsync(string threadId, string runId, string stepId, IEnumerable include = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetRunStepAsync(threadId, runId, stepId, include, context).ConfigureAwait(false); + return Response.FromValue(RunStep.FromResponse(response), response); + } + + /// Retrieves a single run step from a thread run. + /// Identifier of the thread. + /// Identifier of the run. + /// Identifier of the run step. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + /// + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public virtual Response GetRunStep(string threadId, string runId, string stepId, IEnumerable include = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetRunStep(threadId, runId, stepId, include, context); + return Response.FromValue(RunStep.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves a single run step from a thread run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// Identifier of the run step. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + /// + /// The request context, 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 GetRunStepAsync(string threadId, string runId, string stepId, IEnumerable include, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + + using var scope = ClientDiagnostics.CreateScope("RunSteps.GetRunStep"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, include, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves a single run step from a thread run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// Identifier of the run step. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + /// + /// The request context, 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 Response GetRunStep(string threadId, string runId, string stepId, IEnumerable include, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + + using var scope = ClientDiagnostics.CreateScope("RunSteps.GetRunStep"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, include, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of run steps from a thread run. + /// Identifier of the thread. + /// Identifier of the run. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + /// + /// 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 to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalGetRunStepsAsync(string threadId, string runId, IEnumerable include = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalGetRunStepsAsync(threadId, runId, include, limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfRunStep.FromResponse(response), response); + } + + /// Gets a list of run steps from a thread run. + /// Identifier of the thread. + /// Identifier of the run. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + /// + /// 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 to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + internal virtual Response InternalGetRunSteps(string threadId, string runId, IEnumerable include = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalGetRunSteps(threadId, runId, include, limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfRunStep.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of run steps from a thread run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + /// + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual async Task InternalGetRunStepsAsync(string threadId, string runId, IEnumerable include, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("RunSteps.InternalGetRunSteps"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, include, limit, order, after, before, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a list of run steps from a thread run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + /// + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual Response InternalGetRunSteps(string threadId, string runId, IEnumerable include, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("RunSteps.InternalGetRunSteps"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, include, limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateGetRunStepRequest(string threadId, string runId, string stepId, IEnumerable include, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/steps/", false); + uri.AppendPath(stepId, true); + uri.AppendQuery("api-version", _apiVersion, true); + if (include != null && !(include is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("include[]", include, ",", true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateInternalGetRunStepsRequest(string threadId, string runId, IEnumerable include, int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/steps", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (include != null && !(include is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("include[]", include, ",", true); + } + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStreamEvent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStreamEvent.cs new file mode 100644 index 000000000000..71196b3e236a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/RunStreamEvent.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Run operation related streaming events. + public readonly partial struct RunStreamEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStreamEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadRunCreatedValue = "thread.run.created"; + private const string ThreadRunQueuedValue = "thread.run.queued"; + private const string ThreadRunInProgressValue = "thread.run.in_progress"; + private const string ThreadRunRequiresActionValue = "thread.run.requires_action"; + private const string ThreadRunCompletedValue = "thread.run.completed"; + private const string ThreadRunIncompleteValue = "thread.run.incomplete"; + private const string ThreadRunFailedValue = "thread.run.failed"; + private const string ThreadRunCancellingValue = "thread.run.cancelling"; + private const string ThreadRunCancelledValue = "thread.run.cancelled"; + private const string ThreadRunExpiredValue = "thread.run.expired"; + + /// Event sent when a new run is created. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunCreated { get; } = new RunStreamEvent(ThreadRunCreatedValue); + /// Event sent when a run moves to `queued` status. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunQueued { get; } = new RunStreamEvent(ThreadRunQueuedValue); + /// Event sent when a run moves to `in_progress` status. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunInProgress { get; } = new RunStreamEvent(ThreadRunInProgressValue); + /// Event sent when a run moves to `requires_action` status. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunRequiresAction { get; } = new RunStreamEvent(ThreadRunRequiresActionValue); + /// Event sent when a run is completed. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunCompleted { get; } = new RunStreamEvent(ThreadRunCompletedValue); + /// Event sent when a run ends incomplete. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunIncomplete { get; } = new RunStreamEvent(ThreadRunIncompleteValue); + /// Event sent when a run fails. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunFailed { get; } = new RunStreamEvent(ThreadRunFailedValue); + /// Event sent when a run moves to `cancelling` status. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunCancelling { get; } = new RunStreamEvent(ThreadRunCancellingValue); + /// Event sent when a run is cancelled. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunCancelled { get; } = new RunStreamEvent(ThreadRunCancelledValue); + /// Event sent when a run is expired. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunExpired { get; } = new RunStreamEvent(ThreadRunExpiredValue); + /// Determines if two values are the same. + public static bool operator ==(RunStreamEvent left, RunStreamEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStreamEvent left, RunStreamEvent right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RunStreamEvent(string value) => new RunStreamEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStreamEvent other && Equals(other); + /// + public bool Equals(RunStreamEvent 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.Agents.Persistent/src/Generated/Runs.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Runs.cs new file mode 100644 index 000000000000..c9cd90a279d8 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Runs.cs @@ -0,0 +1,1045 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Agents.Persistent +{ + // Data plane generated sub-client. + /// A collection of run operations under `/threads/{threadId}/runs`. + public partial class Runs + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Runs for mocking. + protected Runs() + { + } + + /// Initializes a new instance of Runs. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Runs(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Creates a new run for an agent thread. + /// Identifier of the thread. + /// The ID of the agent that should run the thread. + /// The overridden model name that the agent should use to run the thread. + /// The overridden system instructions that the agent should use to run the thread. + /// + /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior + /// on a per-run basis without overriding other instructions. + /// + /// Adds additional messages to the thread before creating the run. + /// The overridden list of enabled tools that the agent should use to run the thread. + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort + /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// Specifies the format that the model must output. + /// If `true` functions will run in parallel during tool use. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + /// to fetch the file search result content. + /// + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateRunAsync(string threadId, string assistantId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, IEnumerable include = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(assistantId, nameof(assistantId)); + + CreateRunRequest createRunRequest = new CreateRunRequest( + assistantId, + overrideModelName, + overrideInstructions, + additionalInstructions, + additionalMessages?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + stream, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, + parallelToolCalls, + metadata ?? new ChangeTrackingDictionary(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateRunAsync(threadId, createRunRequest.ToRequestContent(), include, context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Creates a new run for an agent thread. + /// Identifier of the thread. + /// The ID of the agent that should run the thread. + /// The overridden model name that the agent should use to run the thread. + /// The overridden system instructions that the agent should use to run the thread. + /// + /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior + /// on a per-run basis without overriding other instructions. + /// + /// Adds additional messages to the thread before creating the run. + /// The overridden list of enabled tools that the agent should use to run the thread. + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort + /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// Specifies the format that the model must output. + /// If `true` functions will run in parallel during tool use. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + /// to fetch the file search result content. + /// + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response CreateRun(string threadId, string assistantId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, IEnumerable include = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(assistantId, nameof(assistantId)); + + CreateRunRequest createRunRequest = new CreateRunRequest( + assistantId, + overrideModelName, + overrideInstructions, + additionalInstructions, + additionalMessages?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + overrideTools?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + stream, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, + parallelToolCalls, + metadata ?? new ChangeTrackingDictionary(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateRun(threadId, createRunRequest.ToRequestContent(), include, context); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new run for an agent thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// The content to send as the body of the request. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + /// to fetch the file search result content. + /// + /// The request context, 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 CreateRunAsync(string threadId, RequestContent content, IEnumerable include = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Runs.CreateRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRunRequest(threadId, content, include, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new run for an agent thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// The content to send as the body of the request. + /// + /// A list of additional fields to include in the response. + /// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + /// to fetch the file search result content. + /// + /// The request context, 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 Response CreateRun(string threadId, RequestContent content, IEnumerable include = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Runs.CreateRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRunRequest(threadId, content, include, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of runs for a specified thread. + /// Identifier of the thread. + /// 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 to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalGetRunsAsync(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalGetRunsAsync(threadId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfThreadRun.FromResponse(response), response); + } + + /// Gets a list of runs for a specified thread. + /// Identifier of the thread. + /// 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 to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response InternalGetRuns(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalGetRuns(threadId, limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of runs for a specified thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual async Task InternalGetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("Runs.InternalGetRuns"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a list of runs for a specified thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual Response InternalGetRuns(string threadId, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("Runs.InternalGetRuns"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets an existing run from an existing thread. + /// Identifier of the thread. + /// Identifier of the run. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetRunAsync(string threadId, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetRunAsync(threadId, runId, context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Gets an existing run from an existing thread. + /// Identifier of the thread. + /// Identifier of the run. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetRun(string threadId, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetRun(threadId, runId, context); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets an existing run from an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// The request context, 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 threadId, string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("Runs.GetRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunRequest(threadId, runId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets an existing run from an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// The request context, 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 Response GetRun(string threadId, string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("Runs.GetRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunRequest(threadId, runId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Modifies an existing thread run. + /// Identifier of the thread. + /// Identifier of the run. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> UpdateRunAsync(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UpdateRunAsync(threadId, runId, updateRunRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Modifies an existing thread run. + /// Identifier of the thread. + /// Identifier of the run. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response UpdateRun(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UpdateRun(threadId, runId, updateRunRequest.ToRequestContent(), context); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Modifies an existing thread run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// The content to send as the body of the request. + /// The request context, 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 UpdateRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Runs.UpdateRun"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Modifies an existing thread run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// The content to send as the body of the request. + /// The request context, 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 Response UpdateRun(string threadId, string runId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Runs.UpdateRun"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Submits outputs from tools as requested by tool calls in a run. + /// Identifier of the thread. + /// Identifier of the run. + /// A list of tools for which the outputs are being submitted. + /// If true, returns a stream of events that happen during the Run as SSE, terminating at `[DONE]`. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> SubmitToolOutputsToRunAsync(string threadId, string runId, IEnumerable toolOutputs, bool? stream = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList(), stream, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await SubmitToolOutputsToRunAsync(threadId, runId, submitToolOutputsToRunRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Submits outputs from tools as requested by tool calls in a run. + /// Identifier of the thread. + /// Identifier of the run. + /// A list of tools for which the outputs are being submitted. + /// If true, returns a stream of events that happen during the Run as SSE, terminating at `[DONE]`. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response SubmitToolOutputsToRun(string threadId, string runId, IEnumerable toolOutputs, bool? stream = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList(), stream, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = SubmitToolOutputsToRun(threadId, runId, submitToolOutputsToRunRequest.ToRequestContent(), context); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Submits outputs from tools as requested by tool calls in a run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// The content to send as the body of the request. + /// The request context, 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 SubmitToolOutputsToRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Runs.SubmitToolOutputsToRun"); + scope.Start(); + try + { + using HttpMessage message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Submits outputs from tools as requested by tool calls in a run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// The content to send as the body of the request. + /// The request context, 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 Response SubmitToolOutputsToRun(string threadId, string runId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Runs.SubmitToolOutputsToRun"); + scope.Start(); + try + { + using HttpMessage message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Cancels a run of an in‐progress thread. + /// Identifier of the thread. + /// Identifier of the run. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> CancelRunAsync(string threadId, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CancelRunAsync(threadId, runId, context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Cancels a run of an in‐progress thread. + /// Identifier of the thread. + /// Identifier of the run. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response CancelRun(string threadId, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CancelRun(threadId, runId, context); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Cancels a run of an in‐progress thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// The request context, 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 CancelRunAsync(string threadId, string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("Runs.CancelRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelRunRequest(threadId, runId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Cancels a run of an in‐progress thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// Identifier of the run. + /// The request context, 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 Response CancelRun(string threadId, string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("Runs.CancelRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelRunRequest(threadId, runId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCreateRunRequest(string threadId, RequestContent content, IEnumerable include, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (include != null && !(include is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("include[]", include, ",", true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalGetRunsRequest(string threadId, int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetRunRequest(string threadId, string runId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUpdateRunRequest(string threadId, string runId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateSubmitToolOutputsToRunRequest(string threadId, string runId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/submit_tool_outputs", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCancelRunRequest(string threadId, string runId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/cancel", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfiguration.Serialization.cs new file mode 100644 index 000000000000..d1f7c62e102f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfiguration.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class SearchConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SearchConfiguration)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("connection_id"u8); + writer.WriteStringValue(ConnectionId); + writer.WritePropertyName("instance_name"u8); + writer.WriteStringValue(InstanceName); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SearchConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SearchConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchConfiguration(document.RootElement, options); + } + + internal static SearchConfiguration DeserializeSearchConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string connectionId = default; + string instanceName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connection_id"u8)) + { + connectionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("instance_name"u8)) + { + instanceName = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchConfiguration(connectionId, instanceName, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SearchConfiguration)} does not support writing '{options.Format}' format."); + } + } + + SearchConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SearchConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchConfiguration(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfiguration.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfiguration.cs new file mode 100644 index 000000000000..5f330943f903 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfiguration.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A custom search configuration. + public partial class SearchConfiguration + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// A connection in a ToolConnectionList attached to this tool. + /// Name of the custom configuration instance given to config. + /// or is null. + public SearchConfiguration(string connectionId, string instanceName) + { + Argument.AssertNotNull(connectionId, nameof(connectionId)); + Argument.AssertNotNull(instanceName, nameof(instanceName)); + + ConnectionId = connectionId; + InstanceName = instanceName; + } + + /// Initializes a new instance of . + /// A connection in a ToolConnectionList attached to this tool. + /// Name of the custom configuration instance given to config. + /// Keeps track of any properties unknown to the library. + internal SearchConfiguration(string connectionId, string instanceName, IDictionary serializedAdditionalRawData) + { + ConnectionId = connectionId; + InstanceName = instanceName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchConfiguration() + { + } + + /// A connection in a ToolConnectionList attached to this tool. + public string ConnectionId { get; set; } + /// Name of the custom configuration instance given to config. + public string InstanceName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfigurationList.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfigurationList.Serialization.cs new file mode 100644 index 000000000000..0f39f3232e32 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfigurationList.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class SearchConfigurationList : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SearchConfigurationList)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("search_configurations"u8); + writer.WriteStartArray(); + foreach (var item in SearchConfigurations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SearchConfigurationList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SearchConfigurationList)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchConfigurationList(document.RootElement, options); + } + + internal static SearchConfigurationList DeserializeSearchConfigurationList(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList searchConfigurations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("search_configurations"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SearchConfiguration.DeserializeSearchConfiguration(item, options)); + } + searchConfigurations = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchConfigurationList(searchConfigurations, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SearchConfigurationList)} does not support writing '{options.Format}' format."); + } + } + + SearchConfigurationList IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchConfigurationList(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchConfigurationList)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SearchConfigurationList FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchConfigurationList(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfigurationList.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfigurationList.cs new file mode 100644 index 000000000000..489407ff8eaf --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SearchConfigurationList.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// A list of search configurations currently used by the `bing_custom_search` tool. + public partial class SearchConfigurationList + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// The connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// is null. + public SearchConfigurationList(IEnumerable searchConfigurations) + { + Argument.AssertNotNull(searchConfigurations, nameof(searchConfigurations)); + + SearchConfigurations = searchConfigurations.ToList(); + } + + /// Initializes a new instance of . + /// + /// The 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 SearchConfigurationList(IList searchConfigurations, IDictionary serializedAdditionalRawData) + { + SearchConfigurations = searchConfigurations; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchConfigurationList() + { + } + + /// + /// The 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.Agents.Persistent/src/Generated/SharepointToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SharepointToolDefinition.Serialization.cs new file mode 100644 index 000000000000..b3aa67e77b06 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SharepointToolDefinition.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class SharepointToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharepointToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("sharepoint_grounding"u8); + writer.WriteObjectValue(SharepointGrounding, options); + } + + SharepointToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharepointToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSharepointToolDefinition(document.RootElement, options); + } + + internal static SharepointToolDefinition DeserializeSharepointToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolConnectionList sharepointGrounding = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sharepoint_grounding"u8)) + { + sharepointGrounding = ToolConnectionList.DeserializeToolConnectionList(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SharepointToolDefinition(type, serializedAdditionalRawData, sharepointGrounding); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SharepointToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + SharepointToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSharepointToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharepointToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new SharepointToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSharepointToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SharepointToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SharepointToolDefinition.cs new file mode 100644 index 000000000000..d537d9561dc5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SharepointToolDefinition.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The input definition information for a sharepoint tool as used to configure an agent. + public partial class SharepointToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + /// The list of connections used by the SharePoint tool. + /// is null. + public SharepointToolDefinition(ToolConnectionList sharepointGrounding) + { + Argument.AssertNotNull(sharepointGrounding, nameof(sharepointGrounding)); + + Type = "sharepoint_grounding"; + SharepointGrounding = sharepointGrounding; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The list of connections used by the SharePoint tool. + internal SharepointToolDefinition(string type, IDictionary serializedAdditionalRawData, ToolConnectionList sharepointGrounding) : base(type, serializedAdditionalRawData) + { + SharepointGrounding = sharepointGrounding; + } + + /// Initializes a new instance of for deserialization. + internal SharepointToolDefinition() + { + } + + /// The list of connections used by the SharePoint tool. + public ToolConnectionList SharepointGrounding { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsAction.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsAction.Serialization.cs new file mode 100644 index 000000000000..637b8bd07549 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsAction.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class SubmitToolOutputsAction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubmitToolOutputsAction)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("submit_tool_outputs"u8); + writer.WriteObjectValue(InternalDetails, options); + } + + SubmitToolOutputsAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubmitToolOutputsAction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubmitToolOutputsAction(document.RootElement, options); + } + + internal static SubmitToolOutputsAction DeserializeSubmitToolOutputsAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalSubmitToolOutputsDetails submitToolOutputs = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("submit_tool_outputs"u8)) + { + submitToolOutputs = InternalSubmitToolOutputsDetails.DeserializeInternalSubmitToolOutputsDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SubmitToolOutputsAction(type, serializedAdditionalRawData, submitToolOutputs); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SubmitToolOutputsAction)} does not support writing '{options.Format}' format."); + } + } + + SubmitToolOutputsAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSubmitToolOutputsAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubmitToolOutputsAction)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new SubmitToolOutputsAction FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSubmitToolOutputsAction(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsAction.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsAction.cs new file mode 100644 index 000000000000..a95b356b2388 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsAction.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The details for required tool calls that must be submitted for an agent thread run to continue. + public partial class SubmitToolOutputsAction : RequiredAction + { + /// Initializes a new instance of . + /// The details describing tools that should be called to submit tool outputs. + /// is null. + internal SubmitToolOutputsAction(InternalSubmitToolOutputsDetails internalDetails) + { + Argument.AssertNotNull(internalDetails, nameof(internalDetails)); + + Type = "submit_tool_outputs"; + InternalDetails = internalDetails; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The details describing tools that should be called to submit tool outputs. + internal SubmitToolOutputsAction(string type, IDictionary serializedAdditionalRawData, InternalSubmitToolOutputsDetails internalDetails) : base(type, serializedAdditionalRawData) + { + InternalDetails = internalDetails; + } + + /// Initializes a new instance of for deserialization. + internal SubmitToolOutputsAction() + { + } + + /// The details describing tools that should be called to submit tool outputs. + public InternalSubmitToolOutputsDetails InternalDetails { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs new file mode 100644 index 000000000000..254446a85814 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class SubmitToolOutputsToRunRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubmitToolOutputsToRunRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("tool_outputs"u8); + writer.WriteStartArray(); + foreach (var item in ToolOutputs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(Stream)) + { + if (Stream != null) + { + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); + } + else + { + writer.WriteNull("stream"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SubmitToolOutputsToRunRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubmitToolOutputsToRunRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubmitToolOutputsToRunRequest(document.RootElement, options); + } + + internal static SubmitToolOutputsToRunRequest DeserializeSubmitToolOutputsToRunRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList toolOutputs = default; + bool? stream = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_outputs"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ToolOutput.DeserializeToolOutput(item, options)); + } + toolOutputs = array; + continue; + } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + stream = null; + continue; + } + stream = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SubmitToolOutputsToRunRequest(toolOutputs, stream, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SubmitToolOutputsToRunRequest)} does not support writing '{options.Format}' format."); + } + } + + SubmitToolOutputsToRunRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSubmitToolOutputsToRunRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubmitToolOutputsToRunRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SubmitToolOutputsToRunRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSubmitToolOutputsToRunRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsToRunRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsToRunRequest.cs new file mode 100644 index 000000000000..8f4a5cc61ed5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/SubmitToolOutputsToRunRequest.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// The SubmitToolOutputsToRunRequest. + internal partial class SubmitToolOutputsToRunRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// A list of tools for which the outputs are being submitted. + /// is null. + internal SubmitToolOutputsToRunRequest(IEnumerable toolOutputs) + { + Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + + ToolOutputs = toolOutputs.ToList(); + } + + /// Initializes a new instance of . + /// A list of tools for which the outputs are being submitted. + /// If true, returns a stream of events that happen during the Run as SSE, terminating at `[DONE]`. + /// Keeps track of any properties unknown to the library. + internal SubmitToolOutputsToRunRequest(IReadOnlyList toolOutputs, bool? stream, IDictionary serializedAdditionalRawData) + { + ToolOutputs = toolOutputs; + Stream = stream; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SubmitToolOutputsToRunRequest() + { + } + + /// A list of tools for which the outputs are being submitted. + public IReadOnlyList ToolOutputs { get; } + /// If true, returns a stream of events that happen during the Run as SSE, terminating at `[DONE]`. + public bool? Stream { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatus.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatus.Serialization.cs new file mode 100644 index 000000000000..f03821f2b858 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatus.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class ThreadDeletionStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadDeletionStatus)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ThreadDeletionStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadDeletionStatus)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadDeletionStatus(document.RootElement, options); + } + + internal static ThreadDeletionStatus DeserializeThreadDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + ThreadDeletionStatusObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("deleted"u8)) + { + deleted = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new ThreadDeletionStatusObject(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ThreadDeletionStatus(id, deleted, @object, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ThreadDeletionStatus)} does not support writing '{options.Format}' format."); + } + } + + ThreadDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeThreadDeletionStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadDeletionStatus)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ThreadDeletionStatus FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeThreadDeletionStatus(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatus.cs new file mode 100644 index 000000000000..d4fa859be490 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatus.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The status of a thread deletion operation. + internal partial class ThreadDeletionStatus + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// is null. + internal ThreadDeletionStatus(string id, bool deleted) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + Deleted = deleted; + } + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// The object type, which is always 'thread.deleted'. + /// Keeps track of any properties unknown to the library. + internal ThreadDeletionStatus(string id, bool deleted, ThreadDeletionStatusObject @object, IDictionary serializedAdditionalRawData) + { + Id = id; + Deleted = deleted; + Object = @object; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ThreadDeletionStatus() + { + } + + /// The ID of the resource specified for deletion. + public string Id { get; } + /// A value indicating whether deletion was successful. + public bool Deleted { get; } + /// The object type, which is always 'thread.deleted'. + public ThreadDeletionStatusObject Object { get; } = ThreadDeletionStatusObject.ThreadDeleted; + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatusObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatusObject.cs new file mode 100644 index 000000000000..e692dc571cf8 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadDeletionStatusObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The ThreadDeletionStatus_object. + internal readonly partial struct ThreadDeletionStatusObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ThreadDeletionStatusObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadDeletedValue = "thread.deleted"; + + /// thread.deleted. + public static ThreadDeletionStatusObject ThreadDeleted { get; } = new ThreadDeletionStatusObject(ThreadDeletedValue); + /// Determines if two values are the same. + public static bool operator ==(ThreadDeletionStatusObject left, ThreadDeletionStatusObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ThreadDeletionStatusObject left, ThreadDeletionStatusObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ThreadDeletionStatusObject(string value) => new ThreadDeletionStatusObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ThreadDeletionStatusObject other && Equals(other); + /// + public bool Equals(ThreadDeletionStatusObject 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.Agents.Persistent/src/Generated/ThreadMessage.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessage.Serialization.cs new file mode 100644 index 000000000000..84bcb9494d2c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessage.Serialization.cs @@ -0,0 +1,376 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ThreadMessage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadMessage)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("thread_id"u8); + writer.WriteStringValue(ThreadId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (IncompleteDetails != null) + { + writer.WritePropertyName("incomplete_details"u8); + writer.WriteObjectValue(IncompleteDetails, options); + } + else + { + writer.WriteNull("incomplete_details"); + } + if (CompletedAt != null) + { + writer.WritePropertyName("completed_at"u8); + writer.WriteNumberValue(CompletedAt.Value, "U"); + } + else + { + writer.WriteNull("completed_at"); + } + if (IncompleteAt != null) + { + writer.WritePropertyName("incomplete_at"u8); + writer.WriteNumberValue(IncompleteAt.Value, "U"); + } + else + { + writer.WriteNull("incomplete_at"); + } + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in ContentItems) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (AssistantId != null) + { + writer.WritePropertyName("assistant_id"u8); + writer.WriteStringValue(AssistantId); + } + else + { + writer.WriteNull("assistant_id"); + } + if (RunId != null) + { + writer.WritePropertyName("run_id"u8); + writer.WriteStringValue(RunId); + } + else + { + writer.WriteNull("run_id"); + } + if (Attachments != null && Optional.IsCollectionDefined(Attachments)) + { + writer.WritePropertyName("attachments"u8); + writer.WriteStartArray(); + foreach (var item in Attachments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("attachments"); + } + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ThreadMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadMessage(document.RootElement, options); + } + + internal static ThreadMessage DeserializeThreadMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + ThreadMessageObject @object = default; + DateTimeOffset createdAt = default; + string threadId = default; + MessageStatus status = default; + MessageIncompleteDetails incompleteDetails = default; + DateTimeOffset? completedAt = default; + DateTimeOffset? incompleteAt = default; + MessageRole role = default; + IReadOnlyList content = default; + string assistantId = default; + string runId = default; + IReadOnlyList attachments = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new ThreadMessageObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("thread_id"u8)) + { + threadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new MessageStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("incomplete_details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + incompleteDetails = null; + continue; + } + incompleteDetails = MessageIncompleteDetails.DeserializeMessageIncompleteDetails(property.Value, options); + continue; + } + if (property.NameEquals("completed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + completedAt = null; + continue; + } + completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("incomplete_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + incompleteAt = null; + continue; + } + incompleteAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("role"u8)) + { + role = new MessageRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageContent.DeserializeMessageContent(item, options)); + } + content = array; + continue; + } + if (property.NameEquals("assistant_id"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + assistantId = null; + continue; + } + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("run_id"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + runId = null; + continue; + } + runId = property.Value.GetString(); + continue; + } + if (property.NameEquals("attachments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + attachments = new ChangeTrackingList(); + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageAttachment.DeserializeMessageAttachment(item, options)); + } + attachments = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ThreadMessage( + id, + @object, + createdAt, + threadId, + status, + incompleteDetails, + completedAt, + incompleteAt, + role, + content, + assistantId, + runId, + attachments, + metadata, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ThreadMessage)} does not support writing '{options.Format}' format."); + } + } + + ThreadMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeThreadMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadMessage)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ThreadMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeThreadMessage(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessage.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessage.cs new file mode 100644 index 000000000000..f60af6f58634 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessage.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// A single, existing message within an agent thread. + public partial class ThreadMessage + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The ID of the thread that this message belongs to. + /// The status of the message. + /// On an incomplete message, details about why the message is incomplete. + /// The Unix timestamp (in seconds) for when the message was completed. + /// The Unix timestamp (in seconds) for when the message was marked as incomplete. + /// The role associated with the agent thread message. + /// + /// The list of content items associated with the agent thread message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// If applicable, the ID of the agent that authored this message. + /// If applicable, the ID of the run associated with the authoring of this message. + /// A list of files attached to the message, and the tools they were added to. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// , or is null. + internal ThreadMessage(string id, DateTimeOffset createdAt, string threadId, MessageStatus status, MessageIncompleteDetails incompleteDetails, DateTimeOffset? completedAt, DateTimeOffset? incompleteAt, MessageRole role, IEnumerable contentItems, string assistantId, string runId, IEnumerable attachments, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(threadId, nameof(threadId)); + Argument.AssertNotNull(contentItems, nameof(contentItems)); + + Id = id; + CreatedAt = createdAt; + ThreadId = threadId; + Status = status; + IncompleteDetails = incompleteDetails; + CompletedAt = completedAt; + IncompleteAt = incompleteAt; + Role = role; + ContentItems = contentItems.ToList(); + AssistantId = assistantId; + RunId = runId; + Attachments = attachments?.ToList(); + Metadata = metadata; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'thread.message'. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The ID of the thread that this message belongs to. + /// The status of the message. + /// On an incomplete message, details about why the message is incomplete. + /// The Unix timestamp (in seconds) for when the message was completed. + /// The Unix timestamp (in seconds) for when the message was marked as incomplete. + /// The role associated with the agent thread message. + /// + /// The list of content items associated with the agent thread message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// If applicable, the ID of the agent that authored this message. + /// If applicable, the ID of the run associated with the authoring of this message. + /// A list of files attached to the message, and the tools they were added to. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal ThreadMessage(string id, ThreadMessageObject @object, DateTimeOffset createdAt, string threadId, MessageStatus status, MessageIncompleteDetails incompleteDetails, DateTimeOffset? completedAt, DateTimeOffset? incompleteAt, MessageRole role, IReadOnlyList contentItems, string assistantId, string runId, IReadOnlyList attachments, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + ThreadId = threadId; + Status = status; + IncompleteDetails = incompleteDetails; + CompletedAt = completedAt; + IncompleteAt = incompleteAt; + Role = role; + ContentItems = contentItems; + AssistantId = assistantId; + RunId = runId; + Attachments = attachments; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ThreadMessage() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always 'thread.message'. + public ThreadMessageObject Object { get; } = ThreadMessageObject.ThreadMessage; + + /// The Unix timestamp, in seconds, representing when this object was created. + public DateTimeOffset CreatedAt { get; } + /// The ID of the thread that this message belongs to. + public string ThreadId { get; } + /// The status of the message. + public MessageStatus Status { get; } + /// On an incomplete message, details about why the message is incomplete. + public MessageIncompleteDetails IncompleteDetails { get; } + /// The Unix timestamp (in seconds) for when the message was completed. + public DateTimeOffset? CompletedAt { get; } + /// The Unix timestamp (in seconds) for when the message was marked as incomplete. + public DateTimeOffset? IncompleteAt { get; } + /// The role associated with the agent thread message. + public MessageRole Role { get; } + /// + /// The list of content items associated with the agent thread message. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public IReadOnlyList ContentItems { get; } + /// If applicable, the ID of the agent that authored this message. + public string AssistantId { get; } + /// If applicable, the ID of the run associated with the authoring of this message. + public string RunId { get; } + /// A list of files attached to the message, and the tools they were added to. + public IReadOnlyList Attachments { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageObject.cs new file mode 100644 index 000000000000..f77ea6b08c47 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The ThreadMessage_object. + public readonly partial struct ThreadMessageObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ThreadMessageObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadMessageValue = "thread.message"; + + /// thread.message. + public static ThreadMessageObject ThreadMessage { get; } = new ThreadMessageObject(ThreadMessageValue); + /// Determines if two values are the same. + public static bool operator ==(ThreadMessageObject left, ThreadMessageObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ThreadMessageObject left, ThreadMessageObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ThreadMessageObject(string value) => new ThreadMessageObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ThreadMessageObject other && Equals(other); + /// + public bool Equals(ThreadMessageObject 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.Agents.Persistent/src/Generated/ThreadMessageOptions.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageOptions.Serialization.cs new file mode 100644 index 000000000000..a4590af129e2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageOptions.Serialization.cs @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ThreadMessageOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadMessageOptions)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (Optional.IsCollectionDefined(Attachments)) + { + if (Attachments != null) + { + writer.WritePropertyName("attachments"u8); + writer.WriteStartArray(); + foreach (var item in Attachments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("attachments"); + } + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ThreadMessageOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadMessageOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadMessageOptions(document.RootElement, options); + } + + internal static ThreadMessageOptions DeserializeThreadMessageOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageRole role = default; + BinaryData content = default; + IList attachments = default; + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("role"u8)) + { + role = new MessageRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + content = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("attachments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageAttachment.DeserializeMessageAttachment(item, options)); + } + attachments = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ThreadMessageOptions(role, content, attachments ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ThreadMessageOptions)} does not support writing '{options.Format}' format."); + } + } + + ThreadMessageOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeThreadMessageOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadMessageOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ThreadMessageOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeThreadMessageOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageOptions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageOptions.cs new file mode 100644 index 000000000000..29f021735adf --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadMessageOptions.cs @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A single message within an agent thread, + /// as provided during that thread's creation for its initial state. + /// + public partial class ThreadMessageOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// The role of the entity that is creating the message. Allowed values include: + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). + /// + /// + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// is null. + public ThreadMessageOptions(MessageRole role, BinaryData content) + { + Argument.AssertNotNull(content, nameof(content)); + + Role = role; + Content = content; + Attachments = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// The role of the entity that is creating the message. Allowed values include: + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). + /// + /// + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// A list of files attached to the message, and the tools they should be added to. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal ThreadMessageOptions(MessageRole role, BinaryData content, IList attachments, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Role = role; + Content = content; + Attachments = attachments; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ThreadMessageOptions() + { + } + + /// + /// The role of the entity that is creating the message. Allowed values include: + /// `user`, which indicates the message is sent by an actual user (and should be + /// used in most cases to represent user-generated messages), and `assistant`, + /// which indicates the message is generated by the agent (use this value to insert + /// messages from the agent into the conversation). + /// + public MessageRole Role { get; } + /// + /// The content of the initial message. This may be a basic string (if you only + /// need text) or an array of typed content blocks (for example, text, image_file, + /// image_url, and so on). + /// + /// 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; } + /// A list of files attached to the message, and the tools they should be added to. + public IList Attachments { get; set; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IDictionary Metadata { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRun.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRun.Serialization.cs new file mode 100644 index 000000000000..2ed6de5c152d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRun.Serialization.cs @@ -0,0 +1,650 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ThreadRun : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadRun)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("thread_id"u8); + writer.WriteStringValue(ThreadId); + writer.WritePropertyName("assistant_id"u8); + writer.WriteStringValue(AssistantId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsDefined(RequiredAction)) + { + if (RequiredAction != null) + { + writer.WritePropertyName("required_action"u8); + writer.WriteObjectValue(RequiredAction, options); + } + else + { + writer.WriteNull("required_action"); + } + } + if (LastError != null) + { + writer.WritePropertyName("last_error"u8); + writer.WriteObjectValue(LastError, options); + } + else + { + writer.WriteNull("last_error"); + } + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + if (ExpiresAt != null) + { + writer.WritePropertyName("expires_at"u8); + writer.WriteNumberValue(ExpiresAt.Value, "U"); + } + else + { + writer.WriteNull("expires_at"); + } + if (StartedAt != null) + { + writer.WritePropertyName("started_at"u8); + writer.WriteNumberValue(StartedAt.Value, "U"); + } + else + { + writer.WriteNull("started_at"); + } + if (CompletedAt != null) + { + writer.WritePropertyName("completed_at"u8); + writer.WriteNumberValue(CompletedAt.Value, "U"); + } + else + { + writer.WriteNull("completed_at"); + } + if (CancelledAt != null) + { + writer.WritePropertyName("cancelled_at"u8); + writer.WriteNumberValue(CancelledAt.Value, "U"); + } + else + { + writer.WriteNull("cancelled_at"); + } + if (FailedAt != null) + { + writer.WritePropertyName("failed_at"u8); + writer.WriteNumberValue(FailedAt.Value, "U"); + } + else + { + writer.WriteNull("failed_at"); + } + if (IncompleteDetails != null) + { + writer.WritePropertyName("incomplete_details"u8); + writer.WriteObjectValue(IncompleteDetails, options); + } + else + { + writer.WriteNull("incomplete_details"); + } + if (Usage != null) + { + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + } + else + { + writer.WriteNull("usage"); + } + if (Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (MaxPromptTokens != null) + { + writer.WritePropertyName("max_prompt_tokens"u8); + writer.WriteNumberValue(MaxPromptTokens.Value); + } + else + { + writer.WriteNull("max_prompt_tokens"); + } + if (MaxCompletionTokens != null) + { + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxCompletionTokens.Value); + } + else + { + writer.WriteNull("max_completion_tokens"); + } + if (TruncationStrategy != null) + { + writer.WritePropertyName("truncation_strategy"u8); + writer.WriteObjectValue(TruncationStrategy, options); + } + else + { + writer.WriteNull("truncation_strategy"); + } + if (ToolChoice != null) + { + writer.WritePropertyName("tool_choice"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ToolChoice); +#else + using (JsonDocument document = JsonDocument.Parse(ToolChoice, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("tool_choice"); + } + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); + } + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + if (Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + } + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCalls); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ThreadRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadRun)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadRun(document.RootElement, options); + } + + internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + ThreadRunObject @object = default; + string threadId = default; + string assistantId = default; + RunStatus status = default; + RequiredAction requiredAction = default; + RunError lastError = default; + string model = default; + string instructions = default; + IReadOnlyList tools = default; + DateTimeOffset createdAt = default; + DateTimeOffset? expiresAt = default; + DateTimeOffset? startedAt = default; + DateTimeOffset? completedAt = default; + DateTimeOffset? cancelledAt = default; + DateTimeOffset? failedAt = default; + IncompleteRunDetails incompleteDetails = default; + RunCompletionUsage usage = default; + float? temperature = default; + float? topP = default; + int? maxPromptTokens = default; + int? maxCompletionTokens = default; + TruncationObject truncationStrategy = default; + BinaryData toolChoice = default; + BinaryData responseFormat = default; + IReadOnlyDictionary metadata = default; + UpdateToolResourcesOptions toolResources = default; + bool parallelToolCalls = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new ThreadRunObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("thread_id"u8)) + { + threadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("assistant_id"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new RunStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("required_action"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + requiredAction = null; + continue; + } + requiredAction = RequiredAction.DeserializeRequiredAction(property.Value, options); + continue; + } + if (property.NameEquals("last_error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastError = null; + continue; + } + lastError = RunError.DeserializeRunError(property.Value, options); + continue; + } + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); + } + tools = array; + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("expires_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + expiresAt = null; + continue; + } + expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("started_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + startedAt = null; + continue; + } + startedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("completed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + completedAt = null; + continue; + } + completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("cancelled_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + cancelledAt = null; + continue; + } + cancelledAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("failed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + failedAt = null; + continue; + } + failedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("incomplete_details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + incompleteDetails = null; + continue; + } + incompleteDetails = IncompleteRunDetails.DeserializeIncompleteRunDetails(property.Value, options); + continue; + } + if (property.NameEquals("usage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + usage = null; + continue; + } + usage = RunCompletionUsage.DeserializeRunCompletionUsage(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("max_prompt_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxPromptTokens = null; + continue; + } + maxPromptTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_completion_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxCompletionTokens = null; + continue; + } + maxCompletionTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("truncation_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + truncationStrategy = null; + continue; + } + truncationStrategy = TruncationObject.DeserializeTruncationObject(property.Value, options); + continue; + } + if (property.NameEquals("tool_choice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolChoice = null; + continue; + } + toolChoice = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; + } + responseFormat = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = UpdateToolResourcesOptions.DeserializeUpdateToolResourcesOptions(property.Value, options); + continue; + } + if (property.NameEquals("parallel_tool_calls"u8)) + { + parallelToolCalls = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ThreadRun( + id, + @object, + threadId, + assistantId, + status, + requiredAction, + lastError, + model, + instructions, + tools, + createdAt, + expiresAt, + startedAt, + completedAt, + cancelledAt, + failedAt, + incompleteDetails, + usage, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, + metadata, + toolResources, + parallelToolCalls, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ThreadRun)} does not support writing '{options.Format}' format."); + } + } + + ThreadRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeThreadRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadRun)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ThreadRun FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeThreadRun(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRun.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRun.cs new file mode 100644 index 000000000000..a76b3a2b04eb --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRun.cs @@ -0,0 +1,343 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// Data representing a single evaluation run of an agent thread. + public partial class ThreadRun + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The ID of the thread associated with this run. + /// The ID of the agent associated with the thread this run was performed against. + /// The status of the agent thread run. + /// The last error, if any, encountered by this agent thread run. + /// The ID of the model to use. + /// The overridden system instructions used for this agent thread run. + /// + /// The overridden enabled tools used for this agent thread run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + /// The Unix timestamp, in seconds, representing when this object was created. + /// The Unix timestamp, in seconds, representing when this item expires. + /// The Unix timestamp, in seconds, representing when this item was started. + /// The Unix timestamp, in seconds, representing when this completed. + /// The Unix timestamp, in seconds, representing when this was cancelled. + /// The Unix timestamp, in seconds, representing when this failed. + /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. + /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + /// The maximum number of prompt tokens specified to have been used over the course of the run. + /// The maximum number of completion tokens specified to have been used over the course of the run. + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// The response format of the tool calls used in this run. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Determines if tools can be executed in parallel within the run. + /// , , , , or is null. + internal ThreadRun(string id, string threadId, string assistantId, RunStatus status, RunError lastError, string model, string instructions, IEnumerable tools, DateTimeOffset createdAt, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IncompleteRunDetails incompleteDetails, RunCompletionUsage usage, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, IReadOnlyDictionary metadata, bool parallelToolCalls) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(threadId, nameof(threadId)); + Argument.AssertNotNull(assistantId, nameof(assistantId)); + Argument.AssertNotNull(model, nameof(model)); + Argument.AssertNotNull(instructions, nameof(instructions)); + Argument.AssertNotNull(tools, nameof(tools)); + + Id = id; + ThreadId = threadId; + AssistantId = assistantId; + Status = status; + LastError = lastError; + Model = model; + Instructions = instructions; + Tools = tools.ToList(); + CreatedAt = createdAt; + ExpiresAt = expiresAt; + StartedAt = startedAt; + CompletedAt = completedAt; + CancelledAt = cancelledAt; + FailedAt = failedAt; + IncompleteDetails = incompleteDetails; + Usage = usage; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolChoice = toolChoice; + ResponseFormat = responseFormat; + Metadata = metadata; + ParallelToolCalls = parallelToolCalls; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'thread.run'. + /// The ID of the thread associated with this run. + /// The ID of the agent associated with the thread this run was performed against. + /// The status of the agent thread run. + /// + /// The details of the action required for the agent thread run to continue. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// The last error, if any, encountered by this agent thread run. + /// The ID of the model to use. + /// The overridden system instructions used for this agent thread run. + /// + /// The overridden enabled tools used for this agent thread run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + /// The Unix timestamp, in seconds, representing when this object was created. + /// The Unix timestamp, in seconds, representing when this item expires. + /// The Unix timestamp, in seconds, representing when this item was started. + /// The Unix timestamp, in seconds, representing when this completed. + /// The Unix timestamp, in seconds, representing when this was cancelled. + /// The Unix timestamp, in seconds, representing when this failed. + /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. + /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + /// The sampling temperature used for this run. If not set, defaults to 1. + /// The nucleus sampling value used for this run. If not set, defaults to 1. + /// The maximum number of prompt tokens specified to have been used over the course of the run. + /// The maximum number of completion tokens specified to have been used over the course of the run. + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// The response format of the tool calls used in this run. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. + /// Determines if tools can be executed in parallel within the run. + /// Keeps track of any properties unknown to the library. + internal ThreadRun(string id, ThreadRunObject @object, string threadId, string assistantId, RunStatus status, RequiredAction requiredAction, RunError lastError, string model, string instructions, IReadOnlyList tools, DateTimeOffset createdAt, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IncompleteRunDetails incompleteDetails, RunCompletionUsage usage, float? temperature, float? topP, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, IReadOnlyDictionary metadata, UpdateToolResourcesOptions toolResources, bool parallelToolCalls, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + ThreadId = threadId; + AssistantId = assistantId; + Status = status; + RequiredAction = requiredAction; + LastError = lastError; + Model = model; + Instructions = instructions; + Tools = tools; + CreatedAt = createdAt; + ExpiresAt = expiresAt; + StartedAt = startedAt; + CompletedAt = completedAt; + CancelledAt = cancelledAt; + FailedAt = failedAt; + IncompleteDetails = incompleteDetails; + Usage = usage; + Temperature = temperature; + TopP = topP; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolChoice = toolChoice; + ResponseFormat = responseFormat; + Metadata = metadata; + ToolResources = toolResources; + ParallelToolCalls = parallelToolCalls; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ThreadRun() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always 'thread.run'. + public ThreadRunObject Object { get; } = ThreadRunObject.ThreadRun; + + /// The ID of the thread associated with this run. + public string ThreadId { get; } + /// The ID of the agent associated with the thread this run was performed against. + public string AssistantId { get; } + /// The status of the agent thread run. + public RunStatus Status { get; } + /// + /// The details of the action required for the agent thread run to continue. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public RequiredAction RequiredAction { get; } + /// The last error, if any, encountered by this agent thread run. + public RunError LastError { get; } + /// The ID of the model to use. + public string Model { get; } + /// The overridden system instructions used for this agent thread run. + public string Instructions { get; } + /// + /// The overridden enabled tools used for this agent thread run. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + public IReadOnlyList Tools { get; } + /// The Unix timestamp, in seconds, representing when this object was created. + public DateTimeOffset CreatedAt { get; } + /// The Unix timestamp, in seconds, representing when this item expires. + public DateTimeOffset? ExpiresAt { get; } + /// The Unix timestamp, in seconds, representing when this item was started. + public DateTimeOffset? StartedAt { get; } + /// The Unix timestamp, in seconds, representing when this completed. + public DateTimeOffset? CompletedAt { get; } + /// The Unix timestamp, in seconds, representing when this was cancelled. + public DateTimeOffset? CancelledAt { get; } + /// The Unix timestamp, in seconds, representing when this failed. + public DateTimeOffset? FailedAt { get; } + /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. + public IncompleteRunDetails IncompleteDetails { get; } + /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + public RunCompletionUsage Usage { get; } + /// The sampling temperature used for this run. If not set, defaults to 1. + public float? Temperature { get; } + /// The nucleus sampling value used for this run. If not set, defaults to 1. + public float? TopP { get; } + /// The maximum number of prompt tokens specified to have been used over the course of the run. + public int? MaxPromptTokens { get; } + /// The maximum number of completion tokens specified to have been used over the course of the run. + public int? MaxCompletionTokens { get; } + /// The strategy to use for dropping messages as the context windows moves forward. + public TruncationObject TruncationStrategy { get; } + /// + /// Controls whether or not and which tool is called by the model. + /// + /// 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; } + /// + /// The response format of the tool calls used in this run. + /// + /// 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 ResponseFormat { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. + public UpdateToolResourcesOptions ToolResources { get; } + /// Determines if tools can be executed in parallel within the run. + public bool ParallelToolCalls { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRunObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRunObject.cs new file mode 100644 index 000000000000..b968df0d3592 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadRunObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The ThreadRun_object. + public readonly partial struct ThreadRunObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ThreadRunObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadRunValue = "thread.run"; + + /// thread.run. + public static ThreadRunObject ThreadRun { get; } = new ThreadRunObject(ThreadRunValue); + /// Determines if two values are the same. + public static bool operator ==(ThreadRunObject left, ThreadRunObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ThreadRunObject left, ThreadRunObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ThreadRunObject(string value) => new ThreadRunObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ThreadRunObject other && Equals(other); + /// + public bool Equals(ThreadRunObject 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.Agents.Persistent/src/Generated/ThreadStreamEvent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadStreamEvent.cs new file mode 100644 index 000000000000..a3231fb6d21d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ThreadStreamEvent.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Thread operation related streaming events. + public readonly partial struct ThreadStreamEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ThreadStreamEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadCreatedValue = "thread.created"; + + /// Event sent when a new thread is created. The data of this event is of type AgentThread. + public static ThreadStreamEvent ThreadCreated { get; } = new ThreadStreamEvent(ThreadCreatedValue); + /// Determines if two values are the same. + public static bool operator ==(ThreadStreamEvent left, ThreadStreamEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ThreadStreamEvent left, ThreadStreamEvent right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ThreadStreamEvent(string value) => new ThreadStreamEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ThreadStreamEvent other && Equals(other); + /// + public bool Equals(ThreadStreamEvent 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.Agents.Persistent/src/Generated/Threads.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Threads.cs new file mode 100644 index 000000000000..6bdfc91c18c0 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/Threads.cs @@ -0,0 +1,714 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Agents.Persistent +{ + // Data plane generated sub-client. + /// A collection of thread operations under `/threads`. + public partial class Threads + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Threads for mocking. + protected Threads() + { + } + + /// Initializes a new instance of Threads. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal Threads(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Creates a new thread. Threads contain messages and can be run by agents. + /// The initial messages to associate with the new thread. + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs. + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + public virtual async Task> CreateThreadAsync(IEnumerable messages = null, ToolResources toolResources = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + CreateThreadRequest createThreadRequest = new CreateThreadRequest(messages?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateThreadAsync(createThreadRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(PersistentAgentThread.FromResponse(response), response); + } + + /// Creates a new thread. Threads contain messages and can be run by agents. + /// The initial messages to associate with the new thread. + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs. + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + public virtual Response CreateThread(IEnumerable messages = null, ToolResources toolResources = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + CreateThreadRequest createThreadRequest = new CreateThreadRequest(messages?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateThread(createThreadRequest.ToRequestContent(), context); + return Response.FromValue(PersistentAgentThread.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by agents. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, 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 CreateThreadAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Threads.CreateThread"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateThreadRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by agents. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, 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 Response CreateThread(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Threads.CreateThread"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateThreadRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of threads that were previously created. + /// 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 to use. + internal virtual async Task> InternalGetThreadsAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalGetThreadsAsync(limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfAgentThread.FromResponse(response), response); + } + + /// Gets a list of threads that were previously created. + /// 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 to use. + internal virtual Response InternalGetThreads(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalGetThreads(limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfAgentThread.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of threads that were previously created. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual async Task InternalGetThreadsAsync(int? limit, string order, string after, string before, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("Threads.InternalGetThreads"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetThreadsRequest(limit, order, after, before, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a list of threads that were previously created. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual Response InternalGetThreads(int? limit, string order, string after, string before, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("Threads.InternalGetThreads"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetThreadsRequest(limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets information about an existing thread. + /// Identifier of the thread. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetThreadAsync(string threadId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetThreadAsync(threadId, context).ConfigureAwait(false); + return Response.FromValue(PersistentAgentThread.FromResponse(response), response); + } + + /// Gets information about an existing thread. + /// Identifier of the thread. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetThread(string threadId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetThread(threadId, context); + return Response.FromValue(PersistentAgentThread.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets information about an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// The request context, 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 GetThreadAsync(string threadId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("Threads.GetThread"); + scope.Start(); + try + { + using HttpMessage message = CreateGetThreadRequest(threadId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets information about an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// The request context, 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 Response GetThread(string threadId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("Threads.GetThread"); + scope.Start(); + try + { + using HttpMessage message = CreateGetThreadRequest(threadId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Modifies an existing thread. + /// The ID of the thread to modify. + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> UpdateThreadAsync(string threadId, ToolResources toolResources = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + UpdateThreadRequest updateThreadRequest = new UpdateThreadRequest(toolResources, metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UpdateThreadAsync(threadId, updateThreadRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(PersistentAgentThread.FromResponse(response), response); + } + + /// Modifies an existing thread. + /// The ID of the thread to modify. + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response UpdateThread(string threadId, ToolResources toolResources = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + UpdateThreadRequest updateThreadRequest = new UpdateThreadRequest(toolResources, metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UpdateThread(threadId, updateThreadRequest.ToRequestContent(), context); + return Response.FromValue(PersistentAgentThread.FromResponse(response), response); + } + + /// + /// [Protocol Method] Modifies an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the thread to modify. + /// The content to send as the body of the request. + /// The request context, 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 UpdateThreadAsync(string threadId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Threads.UpdateThread"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Modifies an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the thread to modify. + /// The content to send as the body of the request. + /// The request context, 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 Response UpdateThread(string threadId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Threads.UpdateThread"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes an existing thread. + /// Identifier of the thread. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalDeleteThreadAsync(string threadId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalDeleteThreadAsync(threadId, context).ConfigureAwait(false); + return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response); + } + + /// Deletes an existing thread. + /// Identifier of the thread. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response InternalDeleteThread(string threadId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalDeleteThread(threadId, context); + return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response); + } + + /// + /// [Protocol Method] Deletes an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// The request context, 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. + internal virtual async Task InternalDeleteThreadAsync(string threadId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("Threads.InternalDeleteThread"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Deletes an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the thread. + /// The request context, 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. + internal virtual Response InternalDeleteThread(string threadId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("Threads.InternalDeleteThread"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCreateThreadRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalGetThreadsRequest(int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetThreadRequest(string threadId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUpdateThreadRequest(string threadId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalDeleteThreadRequest(string threadId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnection.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnection.Serialization.cs new file mode 100644 index 000000000000..79fe67c89359 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnection.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ToolConnection : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolConnection)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("connection_id"u8); + writer.WriteStringValue(ConnectionId); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ToolConnection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolConnection)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolConnection(document.RootElement, options); + } + + internal static ToolConnection DeserializeToolConnection(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string connectionId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connection_id"u8)) + { + connectionId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ToolConnection(connectionId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolConnection)} does not support writing '{options.Format}' format."); + } + } + + ToolConnection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolConnection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolConnection)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ToolConnection FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolConnection(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnection.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnection.cs new file mode 100644 index 000000000000..cc6f72bb901c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnection.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A connection resource. + public partial class ToolConnection + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// A connection in a ToolConnectionList attached to this tool. + /// is null. + public ToolConnection(string connectionId) + { + Argument.AssertNotNull(connectionId, nameof(connectionId)); + + ConnectionId = connectionId; + } + + /// Initializes a new instance of . + /// A connection in a ToolConnectionList attached to this tool. + /// Keeps track of any properties unknown to the library. + internal ToolConnection(string connectionId, IDictionary serializedAdditionalRawData) + { + ConnectionId = connectionId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ToolConnection() + { + } + + /// A connection in a ToolConnectionList attached to this tool. + public string ConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnectionList.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnectionList.Serialization.cs new file mode 100644 index 000000000000..8e8f42ce1a6f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnectionList.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ToolConnectionList : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolConnectionList)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(ConnectionList)) + { + writer.WritePropertyName("connections"u8); + writer.WriteStartArray(); + foreach (var item in ConnectionList) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ToolConnectionList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolConnectionList)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolConnectionList(document.RootElement, options); + } + + internal static ToolConnectionList DeserializeToolConnectionList(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList connections = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connections"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ToolConnection.DeserializeToolConnection(item, options)); + } + connections = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ToolConnectionList(connections ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolConnectionList)} does not support writing '{options.Format}' format."); + } + } + + ToolConnectionList IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolConnectionList(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolConnectionList)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ToolConnectionList FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolConnectionList(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnectionList.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnectionList.cs new file mode 100644 index 000000000000..a6dfc67c583d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolConnectionList.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A set of connection resources currently used by either the `bing_grounding`, `fabric_dataagent`, or `sharepoint_grounding` tools. + public partial class ToolConnectionList + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ToolConnectionList() + { + ConnectionList = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// The 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 ToolConnectionList(IList connectionList, IDictionary serializedAdditionalRawData) + { + ConnectionList = connectionList; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + public IList ConnectionList { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolDefinition.Serialization.cs new file mode 100644 index 000000000000..3da00ebe7b47 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolDefinition.Serialization.cs @@ -0,0 +1,143 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownToolDefinition))] + public partial class ToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolDefinition)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolDefinition(document.RootElement, options); + } + + internal static ToolDefinition DeserializeToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "azure_ai_search": return AzureAISearchToolDefinition.DeserializeAzureAISearchToolDefinition(element, options); + case "azure_function": return AzureFunctionToolDefinition.DeserializeAzureFunctionToolDefinition(element, options); + case "bing_custom_search": return BingCustomSearchToolDefinition.DeserializeBingCustomSearchToolDefinition(element, options); + case "bing_grounding": return BingGroundingToolDefinition.DeserializeBingGroundingToolDefinition(element, options); + case "code_interpreter": return CodeInterpreterToolDefinition.DeserializeCodeInterpreterToolDefinition(element, options); + case "connected_agent": return ConnectedAgentToolDefinition.DeserializeConnectedAgentToolDefinition(element, options); + case "fabric_dataagent": return MicrosoftFabricToolDefinition.DeserializeMicrosoftFabricToolDefinition(element, options); + case "file_search": return FileSearchToolDefinition.DeserializeFileSearchToolDefinition(element, options); + case "function": return FunctionToolDefinition.DeserializeFunctionToolDefinition(element, options); + case "openapi": return OpenApiToolDefinition.DeserializeOpenApiToolDefinition(element, options); + case "sharepoint_grounding": return SharepointToolDefinition.DeserializeSharepointToolDefinition(element, options); + } + } + return UnknownToolDefinition.DeserializeUnknownToolDefinition(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + ToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolDefinition(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolDefinition.cs new file mode 100644 index 000000000000..a632f3baa004 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolDefinition.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An abstract representation of an input tool definition that an agent can use. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + public abstract partial class ToolDefinition + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected ToolDefinition() + { + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal ToolDefinition(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolOutput.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolOutput.Serialization.cs new file mode 100644 index 000000000000..9f4870099aca --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolOutput.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ToolOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolOutput)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ToolCallId)) + { + writer.WritePropertyName("tool_call_id"u8); + writer.WriteStringValue(ToolCallId); + } + if (Optional.IsDefined(Output)) + { + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ToolOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolOutput(document.RootElement, options); + } + + internal static ToolOutput DeserializeToolOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string toolCallId = default; + string output = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_call_id"u8)) + { + toolCallId = property.Value.GetString(); + continue; + } + if (property.NameEquals("output"u8)) + { + output = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ToolOutput(toolCallId, output, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolOutput)} does not support writing '{options.Format}' format."); + } + } + + ToolOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ToolOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolOutput(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolOutput.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolOutput.cs new file mode 100644 index 000000000000..6c70059aa838 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolOutput.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The data provided during a tool outputs submission to resolve pending tool calls and allow the model to continue. + public partial class ToolOutput + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ToolOutput() + { + } + + /// Initializes a new instance of . + /// The ID of the tool call being resolved, as provided in the tool calls of a required action from a run. + /// The output from the tool to be submitted. + /// Keeps track of any properties unknown to the library. + internal ToolOutput(string toolCallId, string output, IDictionary serializedAdditionalRawData) + { + ToolCallId = toolCallId; + Output = output; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The ID of the tool call being resolved, as provided in the tool calls of a required action from a run. + public string ToolCallId { get; set; } + /// The output from the tool to be submitted. + public string Output { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolResources.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolResources.Serialization.cs new file mode 100644 index 000000000000..278980b0c36e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolResources.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class ToolResources : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolResources)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + if (Optional.IsDefined(AzureAISearch)) + { + writer.WritePropertyName("azure_ai_search"u8); + writer.WriteObjectValue(AzureAISearch, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolResources)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolResources(document.RootElement, options); + } + + internal static ToolResources DeserializeToolResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CodeInterpreterToolResource codeInterpreter = default; + FileSearchToolResource fileSearch = default; + AzureAISearchResource azureAiSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + codeInterpreter = CodeInterpreterToolResource.DeserializeCodeInterpreterToolResource(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileSearch = FileSearchToolResource.DeserializeFileSearchToolResource(property.Value, options); + continue; + } + if (property.NameEquals("azure_ai_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + azureAiSearch = AzureAISearchResource.DeserializeAzureAISearchResource(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ToolResources(codeInterpreter, fileSearch, azureAiSearch, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolResources)} does not support writing '{options.Format}' format."); + } + } + + ToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolResources)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ToolResources FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolResources(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolResources.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolResources.cs new file mode 100644 index 000000000000..b4932dbc99d5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/ToolResources.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of + /// tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` + /// tool requires a list of vector store IDs. + /// + public partial class ToolResources + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public ToolResources() + { + } + + /// Initializes a new instance of . + /// Resources to be used by the `code_interpreter` tool consisting of file IDs. + /// Resources to be used by the `file_search` tool consisting of vector store IDs. + /// Resources to be used by the `azure_ai_search` tool consisting of index IDs and names. + /// Keeps track of any properties unknown to the library. + internal ToolResources(CodeInterpreterToolResource codeInterpreter, FileSearchToolResource fileSearch, AzureAISearchResource azureAISearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + AzureAISearch = azureAISearch; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resources to be used by the `code_interpreter` tool consisting of file IDs. + public CodeInterpreterToolResource CodeInterpreter { get; set; } + /// Resources to be used by the `file_search` tool consisting of vector store IDs. + public FileSearchToolResource FileSearch { get; set; } + /// Resources to be used by the `azure_ai_search` tool consisting of index IDs and names. + public AzureAISearchResource AzureAISearch { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationObject.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationObject.Serialization.cs new file mode 100644 index 000000000000..a9754f518c4f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationObject.Serialization.cs @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class TruncationObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TruncationObject)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsDefined(LastMessages)) + { + if (LastMessages != null) + { + writer.WritePropertyName("last_messages"u8); + writer.WriteNumberValue(LastMessages.Value); + } + else + { + writer.WriteNull("last_messages"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TruncationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TruncationObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTruncationObject(document.RootElement, options); + } + + internal static TruncationObject DeserializeTruncationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TruncationStrategy type = default; + int? lastMessages = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new TruncationStrategy(property.Value.GetString()); + continue; + } + if (property.NameEquals("last_messages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastMessages = null; + continue; + } + lastMessages = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TruncationObject(type, lastMessages, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TruncationObject)} does not support writing '{options.Format}' format."); + } + } + + TruncationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTruncationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TruncationObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TruncationObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTruncationObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationObject.cs new file mode 100644 index 000000000000..651754d64319 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationObject.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// Controls for how a thread will be truncated prior to the run. Use this to control the initial + /// context window of the run. + /// + public partial class TruncationObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will + /// be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread + /// will be dropped to fit the context length of the model, `max_prompt_tokens`. + /// + public TruncationObject(TruncationStrategy type) + { + Type = type; + } + + /// Initializes a new instance of . + /// + /// The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will + /// be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread + /// will be dropped to fit the context length of the model, `max_prompt_tokens`. + /// + /// The number of most recent messages from the thread when constructing the context for the run. + /// Keeps track of any properties unknown to the library. + internal TruncationObject(TruncationStrategy type, int? lastMessages, IDictionary serializedAdditionalRawData) + { + Type = type; + LastMessages = lastMessages; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TruncationObject() + { + } + + /// + /// The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will + /// be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread + /// will be dropped to fit the context length of the model, `max_prompt_tokens`. + /// + public TruncationStrategy Type { get; set; } + /// The number of most recent messages from the thread when constructing the context for the run. + public int? LastMessages { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationStrategy.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationStrategy.cs new file mode 100644 index 000000000000..ae0cf797332f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/TruncationStrategy.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Possible truncation strategies for the thread. + public readonly partial struct TruncationStrategy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TruncationStrategy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutoValue = "auto"; + private const string LastMessagesValue = "last_messages"; + + /// Default value. Messages in the middle of the thread will be dropped to fit the context length of the model. + public static TruncationStrategy Auto { get; } = new TruncationStrategy(AutoValue); + /// The thread will truncate to the `lastMessages` count of recent messages. + public static TruncationStrategy LastMessages { get; } = new TruncationStrategy(LastMessagesValue); + /// Determines if two values are the same. + public static bool operator ==(TruncationStrategy left, TruncationStrategy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TruncationStrategy left, TruncationStrategy right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TruncationStrategy(string value) => new TruncationStrategy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TruncationStrategy other && Equals(other); + /// + public bool Equals(TruncationStrategy 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.Agents.Persistent/src/Generated/UnknownMessageContent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageContent.Serialization.cs new file mode 100644 index 000000000000..1b62bb7600eb --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageContent.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownMessageContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + MessageContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageContent(document.RootElement, options); + } + + internal static UnknownMessageContent DeserializeUnknownMessageContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageContent(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageContent)} does not support writing '{options.Format}' format."); + } + } + + MessageContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownMessageContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownMessageContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageContent.cs new file mode 100644 index 000000000000..6de0dbab2f23 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageContent.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of MessageContent. + internal partial class UnknownMessageContent : MessageContent + { + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal UnknownMessageContent(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownMessageContent() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaContent.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaContent.Serialization.cs new file mode 100644 index 000000000000..f923849db4ad --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaContent.Serialization.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownMessageDeltaContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + MessageDeltaContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaContent(document.RootElement, options); + } + + internal static UnknownMessageDeltaContent DeserializeUnknownMessageDeltaContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageDeltaContent(index, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownMessageDeltaContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownMessageDeltaContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaContent.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaContent.cs new file mode 100644 index 000000000000..49a5917228a7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaContent.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of MessageDeltaContent. + internal partial class UnknownMessageDeltaContent : MessageDeltaContent + { + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The type of content for this content part. + /// Keeps track of any properties unknown to the library. + internal UnknownMessageDeltaContent(int index, string type, IDictionary serializedAdditionalRawData) : base(index, type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownMessageDeltaContent() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs new file mode 100644 index 000000000000..a76f76d8fc81 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownMessageDeltaTextAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + MessageDeltaTextAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextAnnotation(document.RootElement, options); + } + + internal static UnknownMessageDeltaTextAnnotation DeserializeUnknownMessageDeltaTextAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageDeltaTextAnnotation(index, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageDeltaTextAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownMessageDeltaTextAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownMessageDeltaTextAnnotation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaTextAnnotation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaTextAnnotation.cs new file mode 100644 index 000000000000..b43d048fe475 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageDeltaTextAnnotation.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of MessageDeltaTextAnnotation. + internal partial class UnknownMessageDeltaTextAnnotation : MessageDeltaTextAnnotation + { + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// Keeps track of any properties unknown to the library. + internal UnknownMessageDeltaTextAnnotation(int index, string type, IDictionary serializedAdditionalRawData) : base(index, type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownMessageDeltaTextAnnotation() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageInputContentBlock.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageInputContentBlock.Serialization.cs new file mode 100644 index 000000000000..fffcff817744 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageInputContentBlock.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownMessageInputContentBlock : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + MessageInputContentBlock IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageInputContentBlock(document.RootElement, options); + } + + internal static UnknownMessageInputContentBlock DeserializeUnknownMessageInputContentBlock(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageBlockType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new MessageBlockType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageInputContentBlock(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support writing '{options.Format}' format."); + } + } + + MessageInputContentBlock IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageInputContentBlock(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageInputContentBlock)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownMessageInputContentBlock FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownMessageInputContentBlock(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageInputContentBlock.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageInputContentBlock.cs new file mode 100644 index 000000000000..a1c1cbc4de69 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageInputContentBlock.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of MessageInputContentBlock. + internal partial class UnknownMessageInputContentBlock : MessageInputContentBlock + { + /// Initializes a new instance of . + /// Specifies which kind of content block this is (text, image_file, image_url, etc.). + /// Keeps track of any properties unknown to the library. + internal UnknownMessageInputContentBlock(MessageBlockType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownMessageInputContentBlock() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageTextAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageTextAnnotation.Serialization.cs new file mode 100644 index 000000000000..f2325c8e09b4 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageTextAnnotation.Serialization.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownMessageTextAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + MessageTextAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextAnnotation(document.RootElement, options); + } + + internal static UnknownMessageTextAnnotation DeserializeUnknownMessageTextAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageTextAnnotation(type, text, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageTextAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMessageTextAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownMessageTextAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownMessageTextAnnotation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageTextAnnotation.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageTextAnnotation.cs new file mode 100644 index 000000000000..911e124a47bc --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownMessageTextAnnotation.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of MessageTextAnnotation. + internal partial class UnknownMessageTextAnnotation : MessageTextAnnotation + { + /// Initializes a new instance of . + /// The object type. + /// The textual content associated with this text annotation item. + /// Keeps track of any properties unknown to the library. + internal UnknownMessageTextAnnotation(string type, string text, IDictionary serializedAdditionalRawData) : base(type, text, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownMessageTextAnnotation() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownOpenApiAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownOpenApiAuthDetails.Serialization.cs new file mode 100644 index 000000000000..523dac0c4ec0 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownOpenApiAuthDetails.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownOpenApiAuthDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var 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); + } + + OpenApiAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiAuthDetails(document.RootElement, options); + } + + internal static UnknownOpenApiAuthDetails DeserializeUnknownOpenApiAuthDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiAuthType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new OpenApiAuthType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownOpenApiAuthDetails(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support writing '{options.Format}' format."); + } + } + + OpenApiAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOpenApiAuthDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownOpenApiAuthDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownOpenApiAuthDetails(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownOpenApiAuthDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownOpenApiAuthDetails.cs new file mode 100644 index 000000000000..ede8bd1e9a26 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownOpenApiAuthDetails.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of OpenApiAuthDetails. + internal partial class UnknownOpenApiAuthDetails : OpenApiAuthDetails + { + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/connection/managed_identity. + /// Keeps track of any properties unknown to the library. + internal UnknownOpenApiAuthDetails(OpenApiAuthType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownOpenApiAuthDetails() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredAction.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredAction.Serialization.cs new file mode 100644 index 000000000000..c33ac9740713 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredAction.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownRequiredAction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredAction)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + RequiredAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredAction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequiredAction(document.RootElement, options); + } + + internal static UnknownRequiredAction DeserializeUnknownRequiredAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRequiredAction(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RequiredAction)} does not support writing '{options.Format}' format."); + } + } + + RequiredAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequiredAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredAction)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownRequiredAction FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownRequiredAction(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredAction.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredAction.cs new file mode 100644 index 000000000000..cf0a643c4f31 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredAction.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of RequiredAction. + internal partial class UnknownRequiredAction : RequiredAction + { + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal UnknownRequiredAction(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRequiredAction() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredToolCall.Serialization.cs new file mode 100644 index 000000000000..191559526968 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredToolCall.Serialization.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownRequiredToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + RequiredToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequiredToolCall(document.RootElement, options); + } + + internal static UnknownRequiredToolCall DeserializeUnknownRequiredToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRequiredToolCall(type, id, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support writing '{options.Format}' format."); + } + } + + RequiredToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRequiredToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownRequiredToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownRequiredToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredToolCall.cs new file mode 100644 index 000000000000..f3573b7f99f3 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRequiredToolCall.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of RequiredToolCall. + internal partial class UnknownRequiredToolCall : RequiredToolCall + { + /// Initializes a new instance of . + /// The object type for the required tool call. + /// The ID of the tool call. This ID must be referenced when submitting tool outputs. + /// Keeps track of any properties unknown to the library. + internal UnknownRequiredToolCall(string type, string id, IDictionary serializedAdditionalRawData) : base(type, id, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRequiredToolCall() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.Serialization.cs new file mode 100644 index 000000000000..c7fb1dd3b417 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownRunStepCodeInterpreterToolCallOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + RunStepCodeInterpreterToolCallOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement, options); + } + + internal static UnknownRunStepCodeInterpreterToolCallOutput DeserializeUnknownRunStepCodeInterpreterToolCallOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepCodeInterpreterToolCallOutput(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepCodeInterpreterToolCallOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownRunStepCodeInterpreterToolCallOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownRunStepCodeInterpreterToolCallOutput(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.cs new file mode 100644 index 000000000000..1ddea1da0260 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of RunStepCodeInterpreterToolCallOutput. + internal partial class UnknownRunStepCodeInterpreterToolCallOutput : RunStepCodeInterpreterToolCallOutput + { + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal UnknownRunStepCodeInterpreterToolCallOutput(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRunStepCodeInterpreterToolCallOutput() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs new file mode 100644 index 000000000000..db06348ea920 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownRunStepDeltaCodeInterpreterOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + RunStepDeltaCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); + } + + internal static UnknownRunStepDeltaCodeInterpreterOutput DeserializeUnknownRunStepDeltaCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDeltaCodeInterpreterOutput(index, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownRunStepDeltaCodeInterpreterOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownRunStepDeltaCodeInterpreterOutput(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.cs new file mode 100644 index 000000000000..72bf3c833968 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of RunStepDeltaCodeInterpreterOutput. + internal partial class UnknownRunStepDeltaCodeInterpreterOutput : RunStepDeltaCodeInterpreterOutput + { + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The type of the streaming run step tool call's Code Interpreter output. + /// Keeps track of any properties unknown to the library. + internal UnknownRunStepDeltaCodeInterpreterOutput(int index, string type, IDictionary serializedAdditionalRawData) : base(index, type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRunStepDeltaCodeInterpreterOutput() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaDetail.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaDetail.Serialization.cs new file mode 100644 index 000000000000..affff47c6a2b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaDetail.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownRunStepDeltaDetail : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + RunStepDeltaDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaDetail(document.RootElement, options); + } + + internal static UnknownRunStepDeltaDetail DeserializeUnknownRunStepDeltaDetail(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDeltaDetail(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaDetail(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownRunStepDeltaDetail FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownRunStepDeltaDetail(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaDetail.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaDetail.cs new file mode 100644 index 000000000000..462b332baa88 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaDetail.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of RunStepDeltaDetail. + internal partial class UnknownRunStepDeltaDetail : RunStepDeltaDetail + { + /// Initializes a new instance of . + /// The object type for the run step detail object. + /// Keeps track of any properties unknown to the library. + internal UnknownRunStepDeltaDetail(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRunStepDeltaDetail() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs new file mode 100644 index 000000000000..36f11e868133 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownRunStepDeltaToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + RunStepDeltaToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaToolCall(document.RootElement, options); + } + + internal static UnknownRunStepDeltaToolCall DeserializeUnknownRunStepDeltaToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string id = default; + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDeltaToolCall(index, id, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDeltaToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownRunStepDeltaToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownRunStepDeltaToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaToolCall.cs new file mode 100644 index 000000000000..a6783d8fc327 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDeltaToolCall.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of RunStepDeltaToolCall. + internal partial class UnknownRunStepDeltaToolCall : RunStepDeltaToolCall + { + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// Keeps track of any properties unknown to the library. + internal UnknownRunStepDeltaToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData) : base(index, id, type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRunStepDeltaToolCall() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDetails.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDetails.Serialization.cs new file mode 100644 index 000000000000..2526750b0c69 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDetails.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownRunStepDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + RunStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDetails(document.RootElement, options); + } + + internal static UnknownRunStepDetails DeserializeUnknownRunStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new RunStepType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDetails(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{options.Format}' format."); + } + } + + RunStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownRunStepDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownRunStepDetails(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDetails.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDetails.cs new file mode 100644 index 000000000000..43dcbd37ffbe --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepDetails.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of RunStepDetails. + internal partial class UnknownRunStepDetails : RunStepDetails + { + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal UnknownRunStepDetails(RunStepType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRunStepDetails() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepToolCall.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepToolCall.Serialization.cs new file mode 100644 index 000000000000..626f00375175 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepToolCall.Serialization.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownRunStepToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + RunStepToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepToolCall(document.RootElement, options); + } + + internal static UnknownRunStepToolCall DeserializeUnknownRunStepToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepToolCall(type, id, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownRunStepToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownRunStepToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepToolCall.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepToolCall.cs new file mode 100644 index 000000000000..2a5404d18adf --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownRunStepToolCall.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of RunStepToolCall. + internal partial class UnknownRunStepToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + internal UnknownRunStepToolCall(string type, string id, IDictionary serializedAdditionalRawData) : base(type, id, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRunStepToolCall() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownToolDefinition.Serialization.cs new file mode 100644 index 000000000000..5a4a4862b74c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownToolDefinition.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + ToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolDefinition(document.RootElement, options); + } + + internal static UnknownToolDefinition DeserializeUnknownToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownToolDefinition(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + ToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownToolDefinition.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownToolDefinition.cs new file mode 100644 index 000000000000..e4ab651bbd6d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownToolDefinition.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of ToolDefinition. + internal partial class UnknownToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal UnknownToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownToolDefinition() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs new file mode 100644 index 000000000000..05e028737225 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownVectorStoreChunkingStrategyRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + VectorStoreChunkingStrategyRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); + } + + internal static UnknownVectorStoreChunkingStrategyRequest DeserializeUnknownVectorStoreChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreChunkingStrategyRequestType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyRequestType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownVectorStoreChunkingStrategyRequest(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreChunkingStrategyRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownVectorStoreChunkingStrategyRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownVectorStoreChunkingStrategyRequest(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyRequest.cs new file mode 100644 index 000000000000..162a057d3f4a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyRequest.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of VectorStoreChunkingStrategyRequest. + internal partial class UnknownVectorStoreChunkingStrategyRequest : VectorStoreChunkingStrategyRequest + { + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal UnknownVectorStoreChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownVectorStoreChunkingStrategyRequest() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs new file mode 100644 index 000000000000..a7f9f986b5f6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UnknownVectorStoreChunkingStrategyResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + VectorStoreChunkingStrategyResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); + } + + internal static UnknownVectorStoreChunkingStrategyResponse DeserializeUnknownVectorStoreChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreChunkingStrategyResponseType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyResponseType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownVectorStoreChunkingStrategyResponse(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreChunkingStrategyResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownVectorStoreChunkingStrategyResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownVectorStoreChunkingStrategyResponse(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyResponse.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyResponse.cs new file mode 100644 index 000000000000..e9652351ae1f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UnknownVectorStoreChunkingStrategyResponse.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Unknown version of VectorStoreChunkingStrategyResponse. + internal partial class UnknownVectorStoreChunkingStrategyResponse : VectorStoreChunkingStrategyResponse + { + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal UnknownVectorStoreChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownVectorStoreChunkingStrategyResponse() + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateAgentRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateAgentRequest.Serialization.cs new file mode 100644 index 000000000000..9e84d36aab8f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateAgentRequest.Serialization.cs @@ -0,0 +1,374 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UpdateAgentRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateAgentRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (Optional.IsDefined(Name)) + { + if (Name != null) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + else + { + writer.WriteNull("name"); + } + } + if (Optional.IsDefined(Description)) + { + if (Description != null) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + else + { + writer.WriteNull("description"); + } + } + if (Optional.IsDefined(Instructions)) + { + if (Instructions != null) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); + } + else + { + writer.WriteNull("instructions"); + } + } + if (Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ToolResources)) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + if (Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); + } + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + UpdateAgentRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateAgentRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateAgentRequest(document.RootElement, options); + } + + internal static UpdateAgentRequest DeserializeUpdateAgentRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string model = default; + string name = default; + string description = default; + string instructions = default; + IReadOnlyList tools = default; + ToolResources toolResources = default; + float? temperature = default; + float? topP = default; + BinaryData responseFormat = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + name = null; + continue; + } + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + description = null; + continue; + } + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + instructions = null; + continue; + } + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); + } + tools = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + toolResources = ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; + } + responseFormat = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UpdateAgentRequest( + model, + name, + description, + instructions, + tools ?? new ChangeTrackingList(), + toolResources, + temperature, + topP, + responseFormat, + metadata ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UpdateAgentRequest)} does not support writing '{options.Format}' format."); + } + } + + UpdateAgentRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateAgentRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateAgentRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UpdateAgentRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateAgentRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateAgentRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateAgentRequest.cs new file mode 100644 index 000000000000..cc206a21fd83 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateAgentRequest.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The UpdateAgentRequest. + internal partial class UpdateAgentRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal UpdateAgentRequest() + { + Tools = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The ID of the model to use. + /// The modified name for the agent to use. + /// The modified description for the agent to use. + /// The modified system instructions for the new agent to use. + /// + /// The modified collection of tools to enable for the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, + /// the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The response format of the tool calls used by this agent. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal UpdateAgentRequest(string model, string name, string description, string instructions, IReadOnlyList tools, ToolResources toolResources, float? temperature, float? topP, BinaryData responseFormat, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Model = model; + Name = name; + Description = description; + Instructions = instructions; + Tools = tools; + ToolResources = toolResources; + Temperature = temperature; + TopP = topP; + ResponseFormat = responseFormat; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The ID of the model to use. + public string Model { get; } + /// The modified name for the agent to use. + public string Name { get; } + /// The modified description for the agent to use. + public string Description { get; } + /// The modified system instructions for the new agent to use. + public string Instructions { get; } + /// + /// The modified collection of tools to enable for the agent. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , , , , , , , and . + /// + public IReadOnlyList Tools { get; } + /// + /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, + /// the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + public ToolResources ToolResources { 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. + /// + 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; } + /// + /// The response format of the tool calls used by this agent. + /// + /// 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 ResponseFormat { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs new file mode 100644 index 000000000000..aa9354e8ef4b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class UpdateCodeInterpreterToolResourceOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateCodeInterpreterToolResourceOptions)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + UpdateCodeInterpreterToolResourceOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateCodeInterpreterToolResourceOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateCodeInterpreterToolResourceOptions(document.RootElement, options); + } + + internal static UpdateCodeInterpreterToolResourceOptions DeserializeUpdateCodeInterpreterToolResourceOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UpdateCodeInterpreterToolResourceOptions(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UpdateCodeInterpreterToolResourceOptions)} does not support writing '{options.Format}' format."); + } + } + + UpdateCodeInterpreterToolResourceOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateCodeInterpreterToolResourceOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateCodeInterpreterToolResourceOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UpdateCodeInterpreterToolResourceOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateCodeInterpreterToolResourceOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateCodeInterpreterToolResourceOptions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateCodeInterpreterToolResourceOptions.cs new file mode 100644 index 000000000000..1f9bea0cb5c5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateCodeInterpreterToolResourceOptions.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Request object to update `code_interpreted` tool resources. + public partial class UpdateCodeInterpreterToolResourceOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public UpdateCodeInterpreterToolResourceOptions() + { + FileIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// A list of file IDs to override the current list of the agent. + /// Keeps track of any properties unknown to the library. + internal UpdateCodeInterpreterToolResourceOptions(IList fileIds, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A list of file IDs to override the current list of the agent. + public IList FileIds { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs new file mode 100644 index 000000000000..0977168f3e31 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class UpdateFileSearchToolResourceOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateFileSearchToolResourceOptions)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(VectorStoreIds)) + { + writer.WritePropertyName("vector_store_ids"u8); + writer.WriteStartArray(); + foreach (var item in VectorStoreIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + UpdateFileSearchToolResourceOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateFileSearchToolResourceOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateFileSearchToolResourceOptions(document.RootElement, options); + } + + internal static UpdateFileSearchToolResourceOptions DeserializeUpdateFileSearchToolResourceOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList vectorStoreIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vector_store_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + vectorStoreIds = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UpdateFileSearchToolResourceOptions(vectorStoreIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UpdateFileSearchToolResourceOptions)} does not support writing '{options.Format}' format."); + } + } + + UpdateFileSearchToolResourceOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateFileSearchToolResourceOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateFileSearchToolResourceOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UpdateFileSearchToolResourceOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateFileSearchToolResourceOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateFileSearchToolResourceOptions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateFileSearchToolResourceOptions.cs new file mode 100644 index 000000000000..70ef70317495 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateFileSearchToolResourceOptions.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Request object to update `file_search` tool resources. + public partial class UpdateFileSearchToolResourceOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public UpdateFileSearchToolResourceOptions() + { + VectorStoreIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// A list of vector store IDs to override the current list of the agent. + /// Keeps track of any properties unknown to the library. + internal UpdateFileSearchToolResourceOptions(IList vectorStoreIds, IDictionary serializedAdditionalRawData) + { + VectorStoreIds = vectorStoreIds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A list of vector store IDs to override the current list of the agent. + public IList VectorStoreIds { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateMessageRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateMessageRequest.Serialization.cs new file mode 100644 index 000000000000..e67a4a110206 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateMessageRequest.Serialization.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UpdateMessageRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateMessageRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + UpdateMessageRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateMessageRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateMessageRequest(document.RootElement, options); + } + + internal static UpdateMessageRequest DeserializeUpdateMessageRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UpdateMessageRequest)} does not support writing '{options.Format}' format."); + } + } + + UpdateMessageRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateMessageRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateMessageRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UpdateMessageRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateMessageRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateMessageRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateMessageRequest.cs new file mode 100644 index 000000000000..015fdd8a9112 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateMessageRequest.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The UpdateMessageRequest. + internal partial class UpdateMessageRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal UpdateMessageRequest() + { + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal UpdateMessageRequest(IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateRunRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateRunRequest.Serialization.cs new file mode 100644 index 000000000000..4cc1fd1dc152 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateRunRequest.Serialization.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UpdateRunRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateRunRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + UpdateRunRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateRunRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateRunRequest(document.RootElement, options); + } + + internal static UpdateRunRequest DeserializeUpdateRunRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UpdateRunRequest)} does not support writing '{options.Format}' format."); + } + } + + UpdateRunRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateRunRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateRunRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UpdateRunRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateRunRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateRunRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateRunRequest.cs new file mode 100644 index 000000000000..6cfe173970ac --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateRunRequest.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The UpdateRunRequest. + internal partial class UpdateRunRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal UpdateRunRequest() + { + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal UpdateRunRequest(IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateThreadRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateThreadRequest.Serialization.cs new file mode 100644 index 000000000000..f81c564fa28a --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateThreadRequest.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + internal partial class UpdateThreadRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + UpdateThreadRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateThreadRequest(document.RootElement, options); + } + + internal static UpdateThreadRequest DeserializeUpdateThreadRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolResources toolResources = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UpdateThreadRequest(toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support writing '{options.Format}' format."); + } + } + + UpdateThreadRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateThreadRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UpdateThreadRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateThreadRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateThreadRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateThreadRequest.cs new file mode 100644 index 000000000000..2463002920b7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateThreadRequest.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The UpdateThreadRequest. + internal partial class UpdateThreadRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal UpdateThreadRequest() + { + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal UpdateThreadRequest(ToolResources toolResources, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + ToolResources = toolResources; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs + /// + public ToolResources ToolResources { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateToolResourcesOptions.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateToolResourcesOptions.Serialization.cs new file mode 100644 index 000000000000..0ff02ef3d4a2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateToolResourcesOptions.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class UpdateToolResourcesOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateToolResourcesOptions)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + if (Optional.IsDefined(AzureAISearch)) + { + writer.WritePropertyName("azure_ai_search"u8); + writer.WriteObjectValue(AzureAISearch, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + UpdateToolResourcesOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateToolResourcesOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateToolResourcesOptions(document.RootElement, options); + } + + internal static UpdateToolResourcesOptions DeserializeUpdateToolResourcesOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpdateCodeInterpreterToolResourceOptions codeInterpreter = default; + UpdateFileSearchToolResourceOptions fileSearch = default; + AzureAISearchResource azureAiSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + codeInterpreter = UpdateCodeInterpreterToolResourceOptions.DeserializeUpdateCodeInterpreterToolResourceOptions(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileSearch = UpdateFileSearchToolResourceOptions.DeserializeUpdateFileSearchToolResourceOptions(property.Value, options); + continue; + } + if (property.NameEquals("azure_ai_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + azureAiSearch = AzureAISearchResource.DeserializeAzureAISearchResource(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UpdateToolResourcesOptions(codeInterpreter, fileSearch, azureAiSearch, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UpdateToolResourcesOptions)} does not support writing '{options.Format}' format."); + } + } + + UpdateToolResourcesOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateToolResourcesOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateToolResourcesOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UpdateToolResourcesOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpdateToolResourcesOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateToolResourcesOptions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateToolResourcesOptions.cs new file mode 100644 index 000000000000..ff39241299ab --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UpdateToolResourcesOptions.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// Request object. A set of resources that are used by the agent's tools. The resources are specific to the type of tool. + /// For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of + /// vector store IDs. + /// + public partial class UpdateToolResourcesOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public UpdateToolResourcesOptions() + { + } + + /// Initializes a new instance of . + /// + /// Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + /// Overrides the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent. + /// Overrides the resources to be used by the `azure_ai_search` tool consisting of index IDs and names. + /// Keeps track of any properties unknown to the library. + internal UpdateToolResourcesOptions(UpdateCodeInterpreterToolResourceOptions codeInterpreter, UpdateFileSearchToolResourceOptions fileSearch, AzureAISearchResource azureAISearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + AzureAISearch = azureAISearch; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + public UpdateCodeInterpreterToolResourceOptions CodeInterpreter { get; set; } + /// Overrides the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent. + public UpdateFileSearchToolResourceOptions FileSearch { get; set; } + /// Overrides the resources to be used by the `azure_ai_search` tool consisting of index IDs and names. + public AzureAISearchResource AzureAISearch { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UploadFileRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UploadFileRequest.Serialization.cs new file mode 100644 index 000000000000..f786e08289e6 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UploadFileRequest.Serialization.cs @@ -0,0 +1,191 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class UploadFileRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UploadFileRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("file"u8); + writer.WriteObjectValue(Data, options); + writer.WritePropertyName("purpose"u8); + writer.WriteStringValue(Purpose.ToString()); + if (Optional.IsDefined(Filename)) + { + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + UploadFileRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UploadFileRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUploadFileRequest(document.RootElement, options); + } + + internal static UploadFileRequest DeserializeUploadFileRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + File file = default; + OpenAIFilePurpose purpose = default; + string filename = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file"u8)) + { + file = File.DeserializeFile(property.Value, options); + continue; + } + if (property.NameEquals("purpose"u8)) + { + purpose = new OpenAIFilePurpose(property.Value.GetString()); + continue; + } + if (property.NameEquals("filename"u8)) + { + filename = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UploadFileRequest(file, purpose, filename, serializedAdditionalRawData); + } + + private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + { + using MultipartFormDataRequestContent content = ToMultipartRequestContent(); + using MemoryStream stream = new MemoryStream(); + content.WriteTo(stream); + if (stream.Position > int.MaxValue) + { + return BinaryData.FromStream(stream); + } + else + { + return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); + } + } + + internal virtual MultipartFormDataRequestContent ToMultipartRequestContent() + { + MultipartFormDataRequestContent content = new MultipartFormDataRequestContent(); + content.Add(ModelReaderWriter.Write(Data, ModelSerializationExtensions.WireOptions), "file"); + content.Add(Purpose.ToString(), "purpose"); + if (Optional.IsDefined(Filename)) + { + content.Add(Filename, "filename"); + } + return content; + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + case "MFD": + return SerializeMultipart(options); + default: + throw new FormatException($"The model {nameof(UploadFileRequest)} does not support writing '{options.Format}' format."); + } + } + + UploadFileRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUploadFileRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UploadFileRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UploadFileRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUploadFileRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UploadFileRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UploadFileRequest.cs new file mode 100644 index 000000000000..409faa1d5b4d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/UploadFileRequest.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The UploadFileRequest. + public partial class UploadFileRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The file data, in bytes. + /// The intended purpose of the uploaded file. Use `assistants` for Agents and Message files, `vision` for Agents image file inputs, `batch` for Batch API, and `fine-tune` for Fine-tuning. + /// is null. + public UploadFileRequest(File data, OpenAIFilePurpose purpose) + { + Argument.AssertNotNull(data, nameof(data)); + + Data = data; + Purpose = purpose; + } + + /// Initializes a new instance of . + /// The file data, in bytes. + /// The intended purpose of the uploaded file. Use `assistants` for Agents and Message files, `vision` for Agents image file inputs, `batch` for Batch API, and `fine-tune` for Fine-tuning. + /// The name of the file. + /// Keeps track of any properties unknown to the library. + internal UploadFileRequest(File data, OpenAIFilePurpose purpose, string filename, IDictionary serializedAdditionalRawData) + { + Data = data; + Purpose = purpose; + Filename = filename; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal UploadFileRequest() + { + } + + /// The file data, in bytes. + public File Data { get; } + /// The intended purpose of the uploaded file. Use `assistants` for Agents and Message files, `vision` for Agents image file inputs, `batch` for Batch API, and `fine-tune` for Fine-tuning. + public OpenAIFilePurpose Purpose { get; } + /// The name of the file. + public string Filename { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStore.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStore.Serialization.cs new file mode 100644 index 000000000000..7ac3dd280deb --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStore.Serialization.cs @@ -0,0 +1,291 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStore : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStore)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("usage_bytes"u8); + writer.WriteNumberValue(UsageBytes); + writer.WritePropertyName("file_counts"u8); + writer.WriteObjectValue(FileCounts, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsDefined(ExpiresAfter)) + { + writer.WritePropertyName("expires_after"u8); + writer.WriteObjectValue(ExpiresAfter, options); + } + if (Optional.IsDefined(ExpiresAt)) + { + if (ExpiresAt != null) + { + writer.WritePropertyName("expires_at"u8); + writer.WriteNumberValue(ExpiresAt.Value, "U"); + } + else + { + writer.WriteNull("expires_at"); + } + } + if (LastActiveAt != null) + { + writer.WritePropertyName("last_active_at"u8); + writer.WriteNumberValue(LastActiveAt.Value, "U"); + } + else + { + writer.WriteNull("last_active_at"); + } + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStore)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStore(document.RootElement, options); + } + + internal static VectorStore DeserializeVectorStore(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + VectorStoreObject @object = default; + DateTimeOffset createdAt = default; + string name = default; + int usageBytes = default; + VectorStoreFileCount fileCounts = default; + VectorStoreStatus status = default; + VectorStoreExpirationPolicy expiresAfter = default; + DateTimeOffset? expiresAt = default; + DateTimeOffset? lastActiveAt = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new VectorStoreObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("usage_bytes"u8)) + { + usageBytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("file_counts"u8)) + { + fileCounts = VectorStoreFileCount.DeserializeVectorStoreFileCount(property.Value, options); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new VectorStoreStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("expires_after"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("expires_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + expiresAt = null; + continue; + } + expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("last_active_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastActiveAt = null; + continue; + } + lastActiveAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStore( + id, + @object, + createdAt, + name, + usageBytes, + fileCounts, + status, + expiresAfter, + expiresAt, + lastActiveAt, + metadata, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStore)} does not support writing '{options.Format}' format."); + } + } + + VectorStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStore)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStore FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStore(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStore.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStore.cs new file mode 100644 index 000000000000..3df0c5b747f1 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStore.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A vector store is a collection of processed files can be used by the `file_search` tool. + public partial class VectorStore + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The Unix timestamp (in seconds) for when the vector store was created. + /// The name of the vector store. + /// The total number of bytes used by the files in the vector store. + /// Files count grouped by status processed or being processed by this vector store. + /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. + /// The Unix timestamp (in seconds) for when the vector store was last active. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// , or is null. + internal VectorStore(string id, DateTimeOffset createdAt, string name, int usageBytes, VectorStoreFileCount fileCounts, VectorStoreStatus status, DateTimeOffset? lastActiveAt, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(fileCounts, nameof(fileCounts)); + + Id = id; + CreatedAt = createdAt; + Name = name; + UsageBytes = usageBytes; + FileCounts = fileCounts; + Status = status; + LastActiveAt = lastActiveAt; + Metadata = metadata; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store`. + /// The Unix timestamp (in seconds) for when the vector store was created. + /// The name of the vector store. + /// The total number of bytes used by the files in the vector store. + /// Files count grouped by status processed or being processed by this vector store. + /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. + /// Details on when this vector store expires. + /// The Unix timestamp (in seconds) for when the vector store will expire. + /// The Unix timestamp (in seconds) for when the vector store was last active. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal VectorStore(string id, VectorStoreObject @object, DateTimeOffset createdAt, string name, int usageBytes, VectorStoreFileCount fileCounts, VectorStoreStatus status, VectorStoreExpirationPolicy expiresAfter, DateTimeOffset? expiresAt, DateTimeOffset? lastActiveAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + Name = name; + UsageBytes = usageBytes; + FileCounts = fileCounts; + Status = status; + ExpiresAfter = expiresAfter; + ExpiresAt = expiresAt; + LastActiveAt = lastActiveAt; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStore() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always `vector_store`. + public VectorStoreObject Object { get; } = VectorStoreObject.VectorStore; + + /// The Unix timestamp (in seconds) for when the vector store was created. + public DateTimeOffset CreatedAt { get; } + /// The name of the vector store. + public string Name { get; } + /// The total number of bytes used by the files in the vector store. + public int UsageBytes { get; } + /// Files count grouped by status processed or being processed by this vector store. + public VectorStoreFileCount FileCounts { get; } + /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. + public VectorStoreStatus Status { get; } + /// Details on when this vector store expires. + public VectorStoreExpirationPolicy ExpiresAfter { get; } + /// The Unix timestamp (in seconds) for when the vector store will expire. + public DateTimeOffset? ExpiresAt { get; } + /// The Unix timestamp (in seconds) for when the vector store was last active. + public DateTimeOffset? LastActiveAt { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs new file mode 100644 index 000000000000..bd4b452b3d24 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreAutoChunkingStrategyRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyRequest)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + VectorStoreAutoChunkingStrategyRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreAutoChunkingStrategyRequest(document.RootElement, options); + } + + internal static VectorStoreAutoChunkingStrategyRequest DeserializeVectorStoreAutoChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreChunkingStrategyRequestType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyRequestType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreAutoChunkingStrategyRequest(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyRequest)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreAutoChunkingStrategyRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreAutoChunkingStrategyRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new VectorStoreAutoChunkingStrategyRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreAutoChunkingStrategyRequest(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyRequest.cs new file mode 100644 index 000000000000..e56519868347 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyRequest.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The default strategy. This strategy currently uses a max_chunk_size_tokens of 800 and chunk_overlap_tokens of 400. + public partial class VectorStoreAutoChunkingStrategyRequest : VectorStoreChunkingStrategyRequest + { + /// Initializes a new instance of . + public VectorStoreAutoChunkingStrategyRequest() + { + Type = VectorStoreChunkingStrategyRequestType.Auto; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal VectorStoreAutoChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs new file mode 100644 index 000000000000..712f02df33f9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreAutoChunkingStrategyResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyResponse)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + VectorStoreAutoChunkingStrategyResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreAutoChunkingStrategyResponse(document.RootElement, options); + } + + internal static VectorStoreAutoChunkingStrategyResponse DeserializeVectorStoreAutoChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreChunkingStrategyResponseType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyResponseType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreAutoChunkingStrategyResponse(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyResponse)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreAutoChunkingStrategyResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreAutoChunkingStrategyResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new VectorStoreAutoChunkingStrategyResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreAutoChunkingStrategyResponse(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyResponse.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyResponse.cs new file mode 100644 index 000000000000..ec5e9b1d0473 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreAutoChunkingStrategyResponse.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the chunking_strategy concept was introduced in the API. + public partial class VectorStoreAutoChunkingStrategyResponse : VectorStoreChunkingStrategyResponse + { + /// Initializes a new instance of . + internal VectorStoreAutoChunkingStrategyResponse() + { + Type = VectorStoreChunkingStrategyResponseType.Other; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal VectorStoreAutoChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs new file mode 100644 index 000000000000..8f6ece0e5a37 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs @@ -0,0 +1,134 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownVectorStoreChunkingStrategyRequest))] + public partial class VectorStoreChunkingStrategyRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreChunkingStrategyRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); + } + + internal static VectorStoreChunkingStrategyRequest DeserializeVectorStoreChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "auto": return VectorStoreAutoChunkingStrategyRequest.DeserializeVectorStoreAutoChunkingStrategyRequest(element, options); + case "static": return VectorStoreStaticChunkingStrategyRequest.DeserializeVectorStoreStaticChunkingStrategyRequest(element, options); + } + } + return UnknownVectorStoreChunkingStrategyRequest.DeserializeUnknownVectorStoreChunkingStrategyRequest(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreChunkingStrategyRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreChunkingStrategyRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequest.cs new file mode 100644 index 000000000000..9cf6167d4534 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequest.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An abstract representation of a vector store chunking strategy configuration. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class VectorStoreChunkingStrategyRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected VectorStoreChunkingStrategyRequest() + { + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal VectorStoreChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type. + internal VectorStoreChunkingStrategyRequestType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequestType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequestType.cs new file mode 100644 index 000000000000..e28424d41687 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyRequestType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Type of chunking strategy. + internal readonly partial struct VectorStoreChunkingStrategyRequestType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreChunkingStrategyRequestType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutoValue = "auto"; + private const string StaticValue = "static"; + + /// auto. + public static VectorStoreChunkingStrategyRequestType Auto { get; } = new VectorStoreChunkingStrategyRequestType(AutoValue); + /// static. + public static VectorStoreChunkingStrategyRequestType Static { get; } = new VectorStoreChunkingStrategyRequestType(StaticValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreChunkingStrategyRequestType left, VectorStoreChunkingStrategyRequestType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreChunkingStrategyRequestType left, VectorStoreChunkingStrategyRequestType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreChunkingStrategyRequestType(string value) => new VectorStoreChunkingStrategyRequestType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreChunkingStrategyRequestType other && Equals(other); + /// + public bool Equals(VectorStoreChunkingStrategyRequestType 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.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs new file mode 100644 index 000000000000..53fcee17c700 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs @@ -0,0 +1,134 @@ +// 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 Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + [PersistableModelProxy(typeof(UnknownVectorStoreChunkingStrategyResponse))] + public partial class VectorStoreChunkingStrategyResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreChunkingStrategyResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); + } + + internal static VectorStoreChunkingStrategyResponse DeserializeVectorStoreChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "other": return VectorStoreAutoChunkingStrategyResponse.DeserializeVectorStoreAutoChunkingStrategyResponse(element, options); + case "static": return VectorStoreStaticChunkingStrategyResponse.DeserializeVectorStoreStaticChunkingStrategyResponse(element, options); + } + } + return UnknownVectorStoreChunkingStrategyResponse.DeserializeUnknownVectorStoreChunkingStrategyResponse(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreChunkingStrategyResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreChunkingStrategyResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponse.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponse.cs new file mode 100644 index 000000000000..3a8e3a5b9a09 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponse.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// An abstract representation of a vector store chunking strategy configuration. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class VectorStoreChunkingStrategyResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected VectorStoreChunkingStrategyResponse() + { + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal VectorStoreChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type. + internal VectorStoreChunkingStrategyResponseType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponseType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponseType.cs new file mode 100644 index 000000000000..02fc03e5d529 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreChunkingStrategyResponseType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Type of chunking strategy. + internal readonly partial struct VectorStoreChunkingStrategyResponseType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreChunkingStrategyResponseType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string OtherValue = "other"; + private const string StaticValue = "static"; + + /// other. + public static VectorStoreChunkingStrategyResponseType Other { get; } = new VectorStoreChunkingStrategyResponseType(OtherValue); + /// static. + public static VectorStoreChunkingStrategyResponseType Static { get; } = new VectorStoreChunkingStrategyResponseType(StaticValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreChunkingStrategyResponseType left, VectorStoreChunkingStrategyResponseType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreChunkingStrategyResponseType left, VectorStoreChunkingStrategyResponseType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreChunkingStrategyResponseType(string value) => new VectorStoreChunkingStrategyResponseType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreChunkingStrategyResponseType other && Equals(other); + /// + public bool Equals(VectorStoreChunkingStrategyResponseType 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.Agents.Persistent/src/Generated/VectorStoreConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfiguration.Serialization.cs new file mode 100644 index 000000000000..2b1ca37b8770 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfiguration.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreConfiguration)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("data_sources"u8); + writer.WriteStartArray(); + foreach (var item in DataSources) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreConfiguration(document.RootElement, options); + } + + internal static VectorStoreConfiguration DeserializeVectorStoreConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList dataSources = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("data_sources"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VectorStoreDataSource.DeserializeVectorStoreDataSource(item, options)); + } + dataSources = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreConfiguration(dataSources, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreConfiguration)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreConfiguration(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfiguration.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfiguration.cs new file mode 100644 index 000000000000..11bdf4120d27 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfiguration.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// Vector storage configuration is the list of data sources, used when multiple + /// files can be used for the enterprise file search. + /// + public partial class VectorStoreConfiguration + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Data sources. + /// is null. + public VectorStoreConfiguration(IEnumerable dataSources) + { + Argument.AssertNotNull(dataSources, nameof(dataSources)); + + DataSources = dataSources.ToList(); + } + + /// Initializes a new instance of . + /// Data sources. + /// Keeps track of any properties unknown to the library. + internal VectorStoreConfiguration(IList dataSources, IDictionary serializedAdditionalRawData) + { + DataSources = dataSources; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreConfiguration() + { + } + + /// Data sources. + public IList DataSources { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfigurations.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfigurations.Serialization.cs new file mode 100644 index 000000000000..98b6e400e6e1 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfigurations.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreConfigurations : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreConfigurations)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("name"u8); + writer.WriteStringValue(StoreName); + writer.WritePropertyName("configuration"u8); + writer.WriteObjectValue(StoreConfiguration, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreConfigurations)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreConfigurations(document.RootElement, options); + } + + internal static VectorStoreConfigurations DeserializeVectorStoreConfigurations(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + VectorStoreConfiguration configuration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("configuration"u8)) + { + configuration = VectorStoreConfiguration.DeserializeVectorStoreConfiguration(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreConfigurations(name, configuration, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreConfigurations)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreConfigurations(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreConfigurations)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreConfigurations FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreConfigurations(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfigurations.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfigurations.cs new file mode 100644 index 000000000000..68e38f91a945 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreConfigurations.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The structure, containing the list of vector storage configurations i.e. the list of azure asset IDs. + public partial class VectorStoreConfigurations + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Name. + /// Configurations. + /// or is null. + public VectorStoreConfigurations(string storeName, VectorStoreConfiguration storeConfiguration) + { + Argument.AssertNotNull(storeName, nameof(storeName)); + Argument.AssertNotNull(storeConfiguration, nameof(storeConfiguration)); + + StoreName = storeName; + StoreConfiguration = storeConfiguration; + } + + /// Initializes a new instance of . + /// Name. + /// Configurations. + /// Keeps track of any properties unknown to the library. + internal VectorStoreConfigurations(string storeName, VectorStoreConfiguration storeConfiguration, IDictionary serializedAdditionalRawData) + { + StoreName = storeName; + StoreConfiguration = storeConfiguration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreConfigurations() + { + } + + /// Name. + public string StoreName { get; set; } + /// Configurations. + public VectorStoreConfiguration StoreConfiguration { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSource.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSource.Serialization.cs new file mode 100644 index 000000000000..c432f5c4b30e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSource.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreDataSource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreDataSource)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("uri"u8); + writer.WriteStringValue(AssetIdentifier); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(AssetType.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreDataSource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreDataSource(document.RootElement, options); + } + + internal static VectorStoreDataSource DeserializeVectorStoreDataSource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string uri = default; + VectorStoreDataSourceAssetType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("uri"u8)) + { + uri = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new VectorStoreDataSourceAssetType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreDataSource(uri, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreDataSource)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreDataSource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreDataSource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreDataSource FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreDataSource(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSource.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSource.cs new file mode 100644 index 000000000000..7bc62b744a63 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSource.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// The structure, containing Azure asset URI path and the asset type of the file used as a data source + /// for the enterprise file search. + /// + public partial class VectorStoreDataSource + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Asset URI. + /// The asset type. + /// is null. + public VectorStoreDataSource(string assetIdentifier, VectorStoreDataSourceAssetType assetType) + { + Argument.AssertNotNull(assetIdentifier, nameof(assetIdentifier)); + + AssetIdentifier = assetIdentifier; + AssetType = assetType; + } + + /// Initializes a new instance of . + /// Asset URI. + /// The asset type. + /// Keeps track of any properties unknown to the library. + internal VectorStoreDataSource(string assetIdentifier, VectorStoreDataSourceAssetType assetType, IDictionary serializedAdditionalRawData) + { + AssetIdentifier = assetIdentifier; + AssetType = assetType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreDataSource() + { + } + + /// Asset URI. + public string AssetIdentifier { get; set; } + /// The asset type. + public VectorStoreDataSourceAssetType AssetType { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSourceAssetType.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSourceAssetType.cs new file mode 100644 index 000000000000..5b9c8144044f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDataSourceAssetType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// + /// Type of vector storage asset. Asset type may be a uri_asset, in this case it should contain asset URI ID, + /// in the case of id_asset it should contain the data ID. + /// + public readonly partial struct VectorStoreDataSourceAssetType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreDataSourceAssetType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UriAssetValue = "uri_asset"; + private const string IdAssetValue = "id_asset"; + + /// Azure URI. + public static VectorStoreDataSourceAssetType UriAsset { get; } = new VectorStoreDataSourceAssetType(UriAssetValue); + /// The data ID. + public static VectorStoreDataSourceAssetType IdAsset { get; } = new VectorStoreDataSourceAssetType(IdAssetValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreDataSourceAssetType left, VectorStoreDataSourceAssetType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreDataSourceAssetType left, VectorStoreDataSourceAssetType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreDataSourceAssetType(string value) => new VectorStoreDataSourceAssetType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreDataSourceAssetType other && Equals(other); + /// + public bool Equals(VectorStoreDataSourceAssetType 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.Agents.Persistent/src/Generated/VectorStoreDeletionStatus.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatus.Serialization.cs new file mode 100644 index 000000000000..5bc93c3ba0b0 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatus.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreDeletionStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreDeletionStatus)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreDeletionStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreDeletionStatus)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreDeletionStatus(document.RootElement, options); + } + + internal static VectorStoreDeletionStatus DeserializeVectorStoreDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + VectorStoreDeletionStatusObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("deleted"u8)) + { + deleted = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new VectorStoreDeletionStatusObject(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreDeletionStatus(id, deleted, @object, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreDeletionStatus)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreDeletionStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreDeletionStatus)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreDeletionStatus FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreDeletionStatus(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatus.cs new file mode 100644 index 000000000000..1d5223d621f2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatus.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Response object for deleting a vector store. + public partial class VectorStoreDeletionStatus + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// is null. + internal VectorStoreDeletionStatus(string id, bool deleted) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + Deleted = deleted; + } + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// The object type, which is always 'vector_store.deleted'. + /// Keeps track of any properties unknown to the library. + internal VectorStoreDeletionStatus(string id, bool deleted, VectorStoreDeletionStatusObject @object, IDictionary serializedAdditionalRawData) + { + Id = id; + Deleted = deleted; + Object = @object; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreDeletionStatus() + { + } + + /// The ID of the resource specified for deletion. + public string Id { get; } + /// A value indicating whether deletion was successful. + public bool Deleted { get; } + /// The object type, which is always 'vector_store.deleted'. + public VectorStoreDeletionStatusObject Object { get; } = VectorStoreDeletionStatusObject.VectorStoreDeleted; + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatusObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatusObject.cs new file mode 100644 index 000000000000..3728d051a734 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreDeletionStatusObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The VectorStoreDeletionStatus_object. + public readonly partial struct VectorStoreDeletionStatusObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreDeletionStatusObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VectorStoreDeletedValue = "vector_store.deleted"; + + /// vector_store.deleted. + public static VectorStoreDeletionStatusObject VectorStoreDeleted { get; } = new VectorStoreDeletionStatusObject(VectorStoreDeletedValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreDeletionStatusObject left, VectorStoreDeletionStatusObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreDeletionStatusObject left, VectorStoreDeletionStatusObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreDeletionStatusObject(string value) => new VectorStoreDeletionStatusObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreDeletionStatusObject other && Equals(other); + /// + public bool Equals(VectorStoreDeletionStatusObject 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.Agents.Persistent/src/Generated/VectorStoreExpirationPolicy.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicy.Serialization.cs new file mode 100644 index 000000000000..6ab6b9763d3f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicy.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreExpirationPolicy : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("anchor"u8); + writer.WriteStringValue(Anchor.ToString()); + writer.WritePropertyName("days"u8); + writer.WriteNumberValue(Days); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreExpirationPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreExpirationPolicy(document.RootElement, options); + } + + internal static VectorStoreExpirationPolicy DeserializeVectorStoreExpirationPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreExpirationPolicyAnchor anchor = default; + int days = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("anchor"u8)) + { + anchor = new VectorStoreExpirationPolicyAnchor(property.Value.GetString()); + continue; + } + if (property.NameEquals("days"u8)) + { + days = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreExpirationPolicy(anchor, days, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreExpirationPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreExpirationPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreExpirationPolicy FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreExpirationPolicy(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicy.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicy.cs new file mode 100644 index 000000000000..35ddfe7ac7be --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicy.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// The expiration policy for a vector store. + public partial class VectorStoreExpirationPolicy + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. + /// The anchor timestamp after which the expiration policy applies. + public VectorStoreExpirationPolicy(VectorStoreExpirationPolicyAnchor anchor, int days) + { + Anchor = anchor; + Days = days; + } + + /// Initializes a new instance of . + /// Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. + /// The anchor timestamp after which the expiration policy applies. + /// Keeps track of any properties unknown to the library. + internal VectorStoreExpirationPolicy(VectorStoreExpirationPolicyAnchor anchor, int days, IDictionary serializedAdditionalRawData) + { + Anchor = anchor; + Days = days; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreExpirationPolicy() + { + } + + /// Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. + public VectorStoreExpirationPolicyAnchor Anchor { get; set; } + /// The anchor timestamp after which the expiration policy applies. + public int Days { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicyAnchor.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicyAnchor.cs new file mode 100644 index 000000000000..34cf0594cb5f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreExpirationPolicyAnchor.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Describes the relationship between the days and the expiration of this vector store. + public readonly partial struct VectorStoreExpirationPolicyAnchor : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreExpirationPolicyAnchor(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string LastActiveAtValue = "last_active_at"; + + /// The expiration policy is based on the last time the vector store was active. + public static VectorStoreExpirationPolicyAnchor LastActiveAt { get; } = new VectorStoreExpirationPolicyAnchor(LastActiveAtValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreExpirationPolicyAnchor left, VectorStoreExpirationPolicyAnchor right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreExpirationPolicyAnchor left, VectorStoreExpirationPolicyAnchor right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreExpirationPolicyAnchor(string value) => new VectorStoreExpirationPolicyAnchor(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreExpirationPolicyAnchor other && Equals(other); + /// + public bool Equals(VectorStoreExpirationPolicyAnchor 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.Agents.Persistent/src/Generated/VectorStoreFile.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFile.Serialization.cs new file mode 100644 index 000000000000..8d0eb3c3120d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFile.Serialization.cs @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFile)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("usage_bytes"u8); + writer.WriteNumberValue(UsageBytes); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("vector_store_id"u8); + writer.WriteStringValue(VectorStoreId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (LastError != null) + { + writer.WritePropertyName("last_error"u8); + writer.WriteObjectValue(LastError, options); + } + else + { + writer.WriteNull("last_error"); + } + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFile(document.RootElement, options); + } + + internal static VectorStoreFile DeserializeVectorStoreFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + VectorStoreFileObject @object = default; + int usageBytes = default; + DateTimeOffset createdAt = default; + string vectorStoreId = default; + VectorStoreFileStatus status = default; + VectorStoreFileError lastError = default; + VectorStoreChunkingStrategyResponse chunkingStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new VectorStoreFileObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("usage_bytes"u8)) + { + usageBytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("vector_store_id"u8)) + { + vectorStoreId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new VectorStoreFileStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("last_error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastError = null; + continue; + } + lastError = VectorStoreFileError.DeserializeVectorStoreFileError(property.Value, options); + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + chunkingStrategy = VectorStoreChunkingStrategyResponse.DeserializeVectorStoreChunkingStrategyResponse(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFile( + id, + @object, + usageBytes, + createdAt, + vectorStoreId, + status, + lastError, + chunkingStrategy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFile)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreFile(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFile.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFile.cs new file mode 100644 index 000000000000..ab2dd9284029 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFile.cs @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Description of a file attached to a vector store. + public partial class VectorStoreFile + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// + /// The total vector store usage in bytes. Note that this may be different from the original file + /// size. + /// + /// The Unix timestamp (in seconds) for when the vector store file was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. + /// The last error associated with this vector store file. Will be `null` if there are no errors. + /// + /// The strategy used to chunk the file. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// , or is null. + internal VectorStoreFile(string id, int usageBytes, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileStatus status, VectorStoreFileError lastError, VectorStoreChunkingStrategyResponse chunkingStrategy) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(chunkingStrategy, nameof(chunkingStrategy)); + + Id = id; + UsageBytes = usageBytes; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + LastError = lastError; + ChunkingStrategy = chunkingStrategy; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store.file`. + /// + /// The total vector store usage in bytes. Note that this may be different from the original file + /// size. + /// + /// The Unix timestamp (in seconds) for when the vector store file was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. + /// The last error associated with this vector store file. Will be `null` if there are no errors. + /// + /// The strategy used to chunk the file. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal VectorStoreFile(string id, VectorStoreFileObject @object, int usageBytes, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileStatus status, VectorStoreFileError lastError, VectorStoreChunkingStrategyResponse chunkingStrategy, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + UsageBytes = usageBytes; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + LastError = lastError; + ChunkingStrategy = chunkingStrategy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreFile() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always `vector_store.file`. + public VectorStoreFileObject Object { get; } = VectorStoreFileObject.VectorStoreFile; + + /// + /// The total vector store usage in bytes. Note that this may be different from the original file + /// size. + /// + public int UsageBytes { get; } + /// The Unix timestamp (in seconds) for when the vector store file was created. + public DateTimeOffset CreatedAt { get; } + /// The ID of the vector store that the file is attached to. + public string VectorStoreId { get; } + /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. + public VectorStoreFileStatus Status { get; } + /// The last error associated with this vector store file. Will be `null` if there are no errors. + public VectorStoreFileError LastError { get; } + /// + /// The strategy used to chunk the file. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public VectorStoreChunkingStrategyResponse ChunkingStrategy { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatch.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatch.Serialization.cs new file mode 100644 index 000000000000..fd0e05a2ddaf --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatch.Serialization.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreFileBatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileBatch)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("vector_store_id"u8); + writer.WriteStringValue(VectorStoreId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("file_counts"u8); + writer.WriteObjectValue(FileCounts, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreFileBatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileBatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileBatch(document.RootElement, options); + } + + internal static VectorStoreFileBatch DeserializeVectorStoreFileBatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + VectorStoreFileBatchObject @object = default; + DateTimeOffset createdAt = default; + string vectorStoreId = default; + VectorStoreFileBatchStatus status = default; + VectorStoreFileCount fileCounts = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new VectorStoreFileBatchObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("vector_store_id"u8)) + { + vectorStoreId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new VectorStoreFileBatchStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("file_counts"u8)) + { + fileCounts = VectorStoreFileCount.DeserializeVectorStoreFileCount(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileBatch( + id, + @object, + createdAt, + vectorStoreId, + status, + fileCounts, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileBatch)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreFileBatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreFileBatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileBatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreFileBatch FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreFileBatch(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatch.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatch.cs new file mode 100644 index 000000000000..71d6827e5c9c --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatch.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A batch of files attached to a vector store. + public partial class VectorStoreFileBatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The Unix timestamp (in seconds) for when the vector store files batch was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. + /// Files count grouped by status processed or being processed by this vector store. + /// , or is null. + internal VectorStoreFileBatch(string id, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileBatchStatus status, VectorStoreFileCount fileCounts) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(fileCounts, nameof(fileCounts)); + + Id = id; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + FileCounts = fileCounts; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store.file_batch`. + /// The Unix timestamp (in seconds) for when the vector store files batch was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. + /// Files count grouped by status processed or being processed by this vector store. + /// Keeps track of any properties unknown to the library. + internal VectorStoreFileBatch(string id, VectorStoreFileBatchObject @object, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileBatchStatus status, VectorStoreFileCount fileCounts, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + FileCounts = fileCounts; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreFileBatch() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always `vector_store.file_batch`. + public VectorStoreFileBatchObject Object { get; } = VectorStoreFileBatchObject.VectorStoreFilesBatch; + + /// The Unix timestamp (in seconds) for when the vector store files batch was created. + public DateTimeOffset CreatedAt { get; } + /// The ID of the vector store that the file is attached to. + public string VectorStoreId { get; } + /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. + public VectorStoreFileBatchStatus Status { get; } + /// Files count grouped by status processed or being processed by this vector store. + public VectorStoreFileCount FileCounts { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatchObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatchObject.cs new file mode 100644 index 000000000000..cf70f9d86d1d --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatchObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The VectorStoreFileBatch_object. + public readonly partial struct VectorStoreFileBatchObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileBatchObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VectorStoreFilesBatchValue = "vector_store.files_batch"; + + /// vector_store.files_batch. + public static VectorStoreFileBatchObject VectorStoreFilesBatch { get; } = new VectorStoreFileBatchObject(VectorStoreFilesBatchValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileBatchObject left, VectorStoreFileBatchObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileBatchObject left, VectorStoreFileBatchObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreFileBatchObject(string value) => new VectorStoreFileBatchObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileBatchObject other && Equals(other); + /// + public bool Equals(VectorStoreFileBatchObject 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.Agents.Persistent/src/Generated/VectorStoreFileBatchStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatchStatus.cs new file mode 100644 index 000000000000..3e91c9cae769 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatchStatus.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The status of the vector store file batch. + public readonly partial struct VectorStoreFileBatchStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileBatchStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string CancelledValue = "cancelled"; + private const string FailedValue = "failed"; + + /// The vector store is still processing this file batch. + public static VectorStoreFileBatchStatus InProgress { get; } = new VectorStoreFileBatchStatus(InProgressValue); + /// the vector store file batch is ready for use. + public static VectorStoreFileBatchStatus Completed { get; } = new VectorStoreFileBatchStatus(CompletedValue); + /// The vector store file batch was cancelled. + public static VectorStoreFileBatchStatus Cancelled { get; } = new VectorStoreFileBatchStatus(CancelledValue); + /// The vector store file batch failed to process. + public static VectorStoreFileBatchStatus Failed { get; } = new VectorStoreFileBatchStatus(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileBatchStatus left, VectorStoreFileBatchStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileBatchStatus left, VectorStoreFileBatchStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreFileBatchStatus(string value) => new VectorStoreFileBatchStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileBatchStatus other && Equals(other); + /// + public bool Equals(VectorStoreFileBatchStatus 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.Agents.Persistent/src/Generated/VectorStoreFileBatches.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatches.cs new file mode 100644 index 000000000000..acc492b5d9b1 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileBatches.cs @@ -0,0 +1,647 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Agents.Persistent +{ + // Data plane generated sub-client. + /// + /// A collection of file-batch operations under + /// `/vector_stores/{vectorStoreId}/file_batches`. + /// + public partial class VectorStoreFileBatches + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of VectorStoreFileBatches for mocking. + protected VectorStoreFileBatches() + { + } + + /// Initializes a new instance of VectorStoreFileBatches. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal VectorStoreFileBatches(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Create a vector store file batch. + /// Identifier of the vector store. + /// List of file identifiers. + /// List of Azure assets. + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateVectorStoreFileBatchAsync(string vectorStoreId, IEnumerable fileIds = null, IEnumerable dataSources = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequest = new CreateVectorStoreFileBatchRequest(fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), dataSources?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), chunkingStrategy, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateVectorStoreFileBatchAsync(vectorStoreId, createVectorStoreFileBatchRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); + } + + /// Create a vector store file batch. + /// Identifier of the vector store. + /// List of file identifiers. + /// List of Azure assets. + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response CreateVectorStoreFileBatch(string vectorStoreId, IEnumerable fileIds = null, IEnumerable dataSources = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequest = new CreateVectorStoreFileBatchRequest(fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), dataSources?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), chunkingStrategy, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateVectorStoreFileBatch(vectorStoreId, createVectorStoreFileBatchRequest.ToRequestContent(), context); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); + } + + /// + /// [Protocol Method] Create a vector store file batch. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// The content to send as the body of the request. + /// The request context, 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 CreateVectorStoreFileBatchAsync(string vectorStoreId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFileBatches.CreateVectorStoreFileBatch"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateVectorStoreFileBatchRequest(vectorStoreId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a vector store file batch. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// The content to send as the body of the request. + /// The request context, 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 Response CreateVectorStoreFileBatch(string vectorStoreId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFileBatches.CreateVectorStoreFileBatch"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateVectorStoreFileBatchRequest(vectorStoreId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieve a vector store file batch. + /// Identifier of the vector store. + /// Identifier of the file batch. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetVectorStoreFileBatchAsync(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetVectorStoreFileBatchAsync(vectorStoreId, batchId, context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); + } + + /// Retrieve a vector store file batch. + /// Identifier of the vector store. + /// Identifier of the file batch. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetVectorStoreFileBatch(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetVectorStoreFileBatch(vectorStoreId, batchId, context); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieve a vector store file batch. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Identifier of the file batch. + /// The request context, 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 GetVectorStoreFileBatchAsync(string vectorStoreId, string batchId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFileBatches.GetVectorStoreFileBatch"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVectorStoreFileBatchRequest(vectorStoreId, batchId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieve a vector store file batch. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Identifier of the file batch. + /// The request context, 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 Response GetVectorStoreFileBatch(string vectorStoreId, string batchId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFileBatches.GetVectorStoreFileBatch"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVectorStoreFileBatchRequest(vectorStoreId, batchId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. + /// Identifier of the vector store. + /// Identifier of the file batch. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> CancelVectorStoreFileBatchAsync(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CancelVectorStoreFileBatchAsync(vectorStoreId, batchId, context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); + } + + /// Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. + /// Identifier of the vector store. + /// Identifier of the file batch. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response CancelVectorStoreFileBatch(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CancelVectorStoreFileBatch(vectorStoreId, batchId, context); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); + } + + /// + /// [Protocol Method] Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Identifier of the file batch. + /// The request context, 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 CancelVectorStoreFileBatchAsync(string vectorStoreId, string batchId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFileBatches.CancelVectorStoreFileBatch"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelVectorStoreFileBatchRequest(vectorStoreId, batchId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Identifier of the file batch. + /// The request context, 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 Response CancelVectorStoreFileBatch(string vectorStoreId, string batchId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFileBatches.CancelVectorStoreFileBatch"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelVectorStoreFileBatchRequest(vectorStoreId, batchId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Returns a list of vector store files in a batch. + /// Identifier of the vector store. + /// Identifier of the file batch. + /// Filter by file status. + /// 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 to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetVectorStoreFileBatchFilesAsync(string vectorStoreId, string batchId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetVectorStoreFileBatchFilesAsync(vectorStoreId, batchId, filter?.ToString(), limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfVectorStoreFile.FromResponse(response), response); + } + + /// Returns a list of vector store files in a batch. + /// Identifier of the vector store. + /// Identifier of the file batch. + /// Filter by file status. + /// 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 to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetVectorStoreFileBatchFiles(string vectorStoreId, string batchId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetVectorStoreFileBatchFiles(vectorStoreId, batchId, filter?.ToString(), limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfVectorStoreFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Returns a list of vector store files in a batch. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Identifier of the file batch. + /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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 GetVectorStoreFileBatchFilesAsync(string vectorStoreId, string batchId, string filter, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFileBatches.GetVectorStoreFileBatchFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVectorStoreFileBatchFilesRequest(vectorStoreId, batchId, filter, limit, order, after, before, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Returns a list of vector store files in a batch. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Identifier of the file batch. + /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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 Response GetVectorStoreFileBatchFiles(string vectorStoreId, string batchId, string filter, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFileBatches.GetVectorStoreFileBatchFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVectorStoreFileBatchFilesRequest(vectorStoreId, batchId, filter, limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCreateVectorStoreFileBatchRequest(string vectorStoreId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCancelVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + uri.AppendPath("/cancel", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetVectorStoreFileBatchFilesRequest(string vectorStoreId, string batchId, string filter, int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + uri.AppendPath("/files", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (filter != null) + { + uri.AppendQuery("filter", filter, true); + } + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileCount.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileCount.Serialization.cs new file mode 100644 index 000000000000..2582d3b67d7e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileCount.Serialization.cs @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreFileCount : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileCount)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("in_progress"u8); + writer.WriteNumberValue(InProgress); + writer.WritePropertyName("completed"u8); + writer.WriteNumberValue(Completed); + writer.WritePropertyName("failed"u8); + writer.WriteNumberValue(Failed); + writer.WritePropertyName("cancelled"u8); + writer.WriteNumberValue(Cancelled); + writer.WritePropertyName("total"u8); + writer.WriteNumberValue(Total); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreFileCount IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileCount)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileCount(document.RootElement, options); + } + + internal static VectorStoreFileCount DeserializeVectorStoreFileCount(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int inProgress = default; + int completed = default; + int failed = default; + int cancelled = default; + int total = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("in_progress"u8)) + { + inProgress = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("completed"u8)) + { + completed = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("failed"u8)) + { + failed = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("cancelled"u8)) + { + cancelled = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("total"u8)) + { + total = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileCount( + inProgress, + completed, + failed, + cancelled, + total, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileCount)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreFileCount IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreFileCount(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileCount)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreFileCount FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreFileCount(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileCount.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileCount.cs new file mode 100644 index 000000000000..4dd3126d7e1b --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileCount.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Counts of files processed or being processed by this vector store grouped by status. + public partial class VectorStoreFileCount + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The number of files that are currently being processed. + /// The number of files that have been successfully processed. + /// The number of files that have failed to process. + /// The number of files that were cancelled. + /// The total number of files. + internal VectorStoreFileCount(int inProgress, int completed, int failed, int cancelled, int total) + { + InProgress = inProgress; + Completed = completed; + Failed = failed; + Cancelled = cancelled; + Total = total; + } + + /// Initializes a new instance of . + /// The number of files that are currently being processed. + /// The number of files that have been successfully processed. + /// The number of files that have failed to process. + /// The number of files that were cancelled. + /// The total number of files. + /// Keeps track of any properties unknown to the library. + internal VectorStoreFileCount(int inProgress, int completed, int failed, int cancelled, int total, IDictionary serializedAdditionalRawData) + { + InProgress = inProgress; + Completed = completed; + Failed = failed; + Cancelled = cancelled; + Total = total; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreFileCount() + { + } + + /// The number of files that are currently being processed. + public int InProgress { get; } + /// The number of files that have been successfully processed. + public int Completed { get; } + /// The number of files that have failed to process. + public int Failed { get; } + /// The number of files that were cancelled. + public int Cancelled { get; } + /// The total number of files. + public int Total { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs new file mode 100644 index 000000000000..2a4dd81345f8 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreFileDeletionStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileDeletionStatus)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreFileDeletionStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileDeletionStatus)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileDeletionStatus(document.RootElement, options); + } + + internal static VectorStoreFileDeletionStatus DeserializeVectorStoreFileDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + VectorStoreFileDeletionStatusObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("deleted"u8)) + { + deleted = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new VectorStoreFileDeletionStatusObject(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileDeletionStatus(id, deleted, @object, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileDeletionStatus)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreFileDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreFileDeletionStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileDeletionStatus)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreFileDeletionStatus FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreFileDeletionStatus(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatus.cs new file mode 100644 index 000000000000..e5e888a81132 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatus.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Response object for deleting a vector store file relationship. + public partial class VectorStoreFileDeletionStatus + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// is null. + internal VectorStoreFileDeletionStatus(string id, bool deleted) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + Deleted = deleted; + } + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// The object type, which is always 'vector_store.deleted'. + /// Keeps track of any properties unknown to the library. + internal VectorStoreFileDeletionStatus(string id, bool deleted, VectorStoreFileDeletionStatusObject @object, IDictionary serializedAdditionalRawData) + { + Id = id; + Deleted = deleted; + Object = @object; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreFileDeletionStatus() + { + } + + /// The ID of the resource specified for deletion. + public string Id { get; } + /// A value indicating whether deletion was successful. + public bool Deleted { get; } + /// The object type, which is always 'vector_store.deleted'. + public VectorStoreFileDeletionStatusObject Object { get; } = VectorStoreFileDeletionStatusObject.VectorStoreFileDeleted; + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatusObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatusObject.cs new file mode 100644 index 000000000000..68251d57c507 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileDeletionStatusObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The VectorStoreFileDeletionStatus_object. + public readonly partial struct VectorStoreFileDeletionStatusObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileDeletionStatusObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VectorStoreFileDeletedValue = "vector_store.file.deleted"; + + /// vector_store.file.deleted. + public static VectorStoreFileDeletionStatusObject VectorStoreFileDeleted { get; } = new VectorStoreFileDeletionStatusObject(VectorStoreFileDeletedValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileDeletionStatusObject left, VectorStoreFileDeletionStatusObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileDeletionStatusObject left, VectorStoreFileDeletionStatusObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreFileDeletionStatusObject(string value) => new VectorStoreFileDeletionStatusObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileDeletionStatusObject other && Equals(other); + /// + public bool Equals(VectorStoreFileDeletionStatusObject 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.Agents.Persistent/src/Generated/VectorStoreFileError.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileError.Serialization.cs new file mode 100644 index 000000000000..e9171b89e3d7 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileError.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreFileError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileError)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code.ToString()); + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreFileError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileError)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileError(document.RootElement, options); + } + + internal static VectorStoreFileError DeserializeVectorStoreFileError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreFileErrorCode code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = new VectorStoreFileErrorCode(property.Value.GetString()); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileError(code, message, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileError)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreFileError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreFileError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileError)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreFileError FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreFileError(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileError.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileError.cs new file mode 100644 index 000000000000..6485141890a3 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileError.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Details on the error that may have occurred while processing a file for this vector store. + public partial class VectorStoreFileError + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// One of `server_error` or `rate_limit_exceeded`. + /// A human-readable description of the error. + /// is null. + internal VectorStoreFileError(VectorStoreFileErrorCode code, string message) + { + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + } + + /// Initializes a new instance of . + /// One of `server_error` or `rate_limit_exceeded`. + /// A human-readable description of the error. + /// Keeps track of any properties unknown to the library. + internal VectorStoreFileError(VectorStoreFileErrorCode code, string message, IDictionary serializedAdditionalRawData) + { + Code = code; + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreFileError() + { + } + + /// One of `server_error` or `rate_limit_exceeded`. + public VectorStoreFileErrorCode Code { get; } + /// A human-readable description of the error. + public string Message { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileErrorCode.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileErrorCode.cs new file mode 100644 index 000000000000..bf4bbd517cb2 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileErrorCode.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Error code variants for vector store file processing. + public readonly partial struct VectorStoreFileErrorCode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileErrorCode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ServerErrorValue = "server_error"; + private const string InvalidFileValue = "invalid_file"; + private const string UnsupportedFileValue = "unsupported_file"; + + /// An server error occurred. + public static VectorStoreFileErrorCode ServerError { get; } = new VectorStoreFileErrorCode(ServerErrorValue); + /// The file is not valid. + public static VectorStoreFileErrorCode InvalidFile { get; } = new VectorStoreFileErrorCode(InvalidFileValue); + /// The file is of unsupported type. + public static VectorStoreFileErrorCode UnsupportedFile { get; } = new VectorStoreFileErrorCode(UnsupportedFileValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileErrorCode left, VectorStoreFileErrorCode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileErrorCode left, VectorStoreFileErrorCode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreFileErrorCode(string value) => new VectorStoreFileErrorCode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileErrorCode other && Equals(other); + /// + public bool Equals(VectorStoreFileErrorCode 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.Agents.Persistent/src/Generated/VectorStoreFileObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileObject.cs new file mode 100644 index 000000000000..e2502738bc3f --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The VectorStoreFile_object. + public readonly partial struct VectorStoreFileObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VectorStoreFileValue = "vector_store.file"; + + /// vector_store.file. + public static VectorStoreFileObject VectorStoreFile { get; } = new VectorStoreFileObject(VectorStoreFileValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileObject left, VectorStoreFileObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileObject left, VectorStoreFileObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreFileObject(string value) => new VectorStoreFileObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileObject other && Equals(other); + /// + public bool Equals(VectorStoreFileObject 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.Agents.Persistent/src/Generated/VectorStoreFileStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileStatus.cs new file mode 100644 index 000000000000..534061c068d1 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileStatus.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Vector store file status. + public readonly partial struct VectorStoreFileStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string FailedValue = "failed"; + private const string CancelledValue = "cancelled"; + + /// The file is currently being processed. + public static VectorStoreFileStatus InProgress { get; } = new VectorStoreFileStatus(InProgressValue); + /// The file has been successfully processed. + public static VectorStoreFileStatus Completed { get; } = new VectorStoreFileStatus(CompletedValue); + /// The file has failed to process. + public static VectorStoreFileStatus Failed { get; } = new VectorStoreFileStatus(FailedValue); + /// The file was cancelled. + public static VectorStoreFileStatus Cancelled { get; } = new VectorStoreFileStatus(CancelledValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileStatus left, VectorStoreFileStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileStatus left, VectorStoreFileStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreFileStatus(string value) => new VectorStoreFileStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileStatus other && Equals(other); + /// + public bool Equals(VectorStoreFileStatus 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.Agents.Persistent/src/Generated/VectorStoreFileStatusFilter.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileStatusFilter.cs new file mode 100644 index 000000000000..090574bfaacf --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFileStatusFilter.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Query parameter filter for vector store file retrieval endpoint. + public readonly partial struct VectorStoreFileStatusFilter : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileStatusFilter(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string FailedValue = "failed"; + private const string CancelledValue = "cancelled"; + + /// Retrieve only files that are currently being processed. + public static VectorStoreFileStatusFilter InProgress { get; } = new VectorStoreFileStatusFilter(InProgressValue); + /// Retrieve only files that have been successfully processed. + public static VectorStoreFileStatusFilter Completed { get; } = new VectorStoreFileStatusFilter(CompletedValue); + /// Retrieve only files that have failed to process. + public static VectorStoreFileStatusFilter Failed { get; } = new VectorStoreFileStatusFilter(FailedValue); + /// Retrieve only files that were cancelled. + public static VectorStoreFileStatusFilter Cancelled { get; } = new VectorStoreFileStatusFilter(CancelledValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileStatusFilter left, VectorStoreFileStatusFilter right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileStatusFilter left, VectorStoreFileStatusFilter right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreFileStatusFilter(string value) => new VectorStoreFileStatusFilter(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileStatusFilter other && Equals(other); + /// + public bool Equals(VectorStoreFileStatusFilter 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.Agents.Persistent/src/Generated/VectorStoreFiles.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFiles.cs new file mode 100644 index 000000000000..8acef460de36 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreFiles.cs @@ -0,0 +1,635 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Agents.Persistent +{ + // Data plane generated sub-client. + /// + /// A collection of vector-store file operations under + /// `/vector_stores/{vectorStoreId}/files`. + /// + public partial class VectorStoreFiles + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of VectorStoreFiles for mocking. + protected VectorStoreFiles() + { + } + + /// Initializes a new instance of VectorStoreFiles. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal VectorStoreFiles(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Returns a list of vector store files. + /// Identifier of the vector store. + /// Filter by file status. + /// 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 to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalListFilesAsync(string vectorStoreId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalListFilesAsync(vectorStoreId, filter?.ToString(), limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfVectorStoreFile.FromResponse(response), response); + } + + /// Returns a list of vector store files. + /// Identifier of the vector store. + /// Filter by file status. + /// 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 to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response InternalListFiles(string vectorStoreId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalListFiles(vectorStoreId, filter?.ToString(), limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfVectorStoreFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Returns a list of vector store files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual async Task InternalListFilesAsync(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFiles.InternalListFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalListFilesRequest(vectorStoreId, filter, limit, order, after, before, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Returns a list of vector store files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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. + internal virtual Response InternalListFiles(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFiles.InternalListFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalListFilesRequest(vectorStoreId, filter, limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Create a vector store file by attaching a file to a vector store. + /// Identifier of the vector store. + /// Identifier of the file. + /// Azure asset ID. + /// The chunking strategy used to chunk the file. If not set, uses the auto strategy. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateVectorStoreFileAsync(string vectorStoreId, string fileId = null, VectorStoreDataSource dataSource = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + CreateVectorStoreFileRequest createVectorStoreFileRequest = new CreateVectorStoreFileRequest(fileId, dataSource, chunkingStrategy, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateVectorStoreFileAsync(vectorStoreId, createVectorStoreFileRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFile.FromResponse(response), response); + } + + /// Create a vector store file by attaching a file to a vector store. + /// Identifier of the vector store. + /// Identifier of the file. + /// Azure asset ID. + /// The chunking strategy used to chunk the file. If not set, uses the auto strategy. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response CreateVectorStoreFile(string vectorStoreId, string fileId = null, VectorStoreDataSource dataSource = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + CreateVectorStoreFileRequest createVectorStoreFileRequest = new CreateVectorStoreFileRequest(fileId, dataSource, chunkingStrategy, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateVectorStoreFile(vectorStoreId, createVectorStoreFileRequest.ToRequestContent(), context); + return Response.FromValue(VectorStoreFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Create a vector store file by attaching a file to a vector store. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// The content to send as the body of the request. + /// The request context, 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 CreateVectorStoreFileAsync(string vectorStoreId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFiles.CreateVectorStoreFile"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateVectorStoreFileRequest(vectorStoreId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a vector store file by attaching a file to a vector store. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// The content to send as the body of the request. + /// The request context, 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 Response CreateVectorStoreFile(string vectorStoreId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFiles.CreateVectorStoreFile"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateVectorStoreFileRequest(vectorStoreId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves a vector store file. + /// Identifier of the vector store. + /// Identifier of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetVectorStoreFileAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetVectorStoreFileAsync(vectorStoreId, fileId, context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFile.FromResponse(response), response); + } + + /// Retrieves a vector store file. + /// Identifier of the vector store. + /// Identifier of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetVectorStoreFile(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetVectorStoreFile(vectorStoreId, fileId, context); + return Response.FromValue(VectorStoreFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves a vector store file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Identifier of the file. + /// The request context, 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 GetVectorStoreFileAsync(string vectorStoreId, string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFiles.GetVectorStoreFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVectorStoreFileRequest(vectorStoreId, fileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves a vector store file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Identifier of the file. + /// The request context, 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 Response GetVectorStoreFile(string vectorStoreId, string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFiles.GetVectorStoreFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVectorStoreFileRequest(vectorStoreId, fileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a vector store file. This removes the file‐to‐store link (does not delete the file itself). + /// Identifier of the vector store. + /// Identifier of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> DeleteVectorStoreFileAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await DeleteVectorStoreFileAsync(vectorStoreId, fileId, context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFileDeletionStatus.FromResponse(response), response); + } + + /// Deletes a vector store file. This removes the file‐to‐store link (does not delete the file itself). + /// Identifier of the vector store. + /// Identifier of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response DeleteVectorStoreFile(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = DeleteVectorStoreFile(vectorStoreId, fileId, context); + return Response.FromValue(VectorStoreFileDeletionStatus.FromResponse(response), response); + } + + /// + /// [Protocol Method] Deletes a vector store file. This removes the file‐to‐store link (does not delete the file itself). + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Identifier of the file. + /// The request context, 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 DeleteVectorStoreFileAsync(string vectorStoreId, string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFiles.DeleteVectorStoreFile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteVectorStoreFileRequest(vectorStoreId, fileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Deletes a vector store file. This removes the file‐to‐store link (does not delete the file itself). + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// Identifier of the file. + /// The request context, 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 Response DeleteVectorStoreFile(string vectorStoreId, string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStoreFiles.DeleteVectorStoreFile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteVectorStoreFileRequest(vectorStoreId, fileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateInternalListFilesRequest(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (filter != null) + { + uri.AppendQuery("filter", filter, true); + } + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateVectorStoreFileRequest(string vectorStoreId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetVectorStoreFileRequest(string vectorStoreId, string fileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteVectorStoreFileRequest(string vectorStoreId, string fileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreObject.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreObject.cs new file mode 100644 index 000000000000..90ad1cb720ee --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// The VectorStore_object. + public readonly partial struct VectorStoreObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VectorStoreValue = "vector_store"; + + /// vector_store. + public static VectorStoreObject VectorStore { get; } = new VectorStoreObject(VectorStoreValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreObject left, VectorStoreObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreObject left, VectorStoreObject right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreObject(string value) => new VectorStoreObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreObject other && Equals(other); + /// + public bool Equals(VectorStoreObject 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.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs new file mode 100644 index 000000000000..9407e0909a40 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreStaticChunkingStrategyOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.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) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyOptions)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("max_chunk_size_tokens"u8); + writer.WriteNumberValue(MaxChunkSizeTokens); + writer.WritePropertyName("chunk_overlap_tokens"u8); + writer.WriteNumberValue(ChunkOverlapTokens); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VectorStoreStaticChunkingStrategyOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreStaticChunkingStrategyOptions(document.RootElement, options); + } + + internal static VectorStoreStaticChunkingStrategyOptions DeserializeVectorStoreStaticChunkingStrategyOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int maxChunkSizeTokens = default; + int chunkOverlapTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("max_chunk_size_tokens"u8)) + { + maxChunkSizeTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("chunk_overlap_tokens"u8)) + { + chunkOverlapTokens = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreStaticChunkingStrategyOptions(maxChunkSizeTokens, chunkOverlapTokens, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyOptions)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreStaticChunkingStrategyOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreStaticChunkingStrategyOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreStaticChunkingStrategyOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreStaticChunkingStrategyOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyOptions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyOptions.cs new file mode 100644 index 000000000000..bbe534ef23a9 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyOptions.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// Options to configure a vector store static chunking strategy. + public partial class VectorStoreStaticChunkingStrategyOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. + /// + /// The number of tokens that overlap between chunks. The default value is 400. + /// Note that the overlap must not exceed half of max_chunk_size_tokens. + /// + public VectorStoreStaticChunkingStrategyOptions(int maxChunkSizeTokens, int chunkOverlapTokens) + { + MaxChunkSizeTokens = maxChunkSizeTokens; + ChunkOverlapTokens = chunkOverlapTokens; + } + + /// Initializes a new instance of . + /// The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. + /// + /// The number of tokens that overlap between chunks. The default value is 400. + /// Note that the overlap must not exceed half of max_chunk_size_tokens. + /// + /// Keeps track of any properties unknown to the library. + internal VectorStoreStaticChunkingStrategyOptions(int maxChunkSizeTokens, int chunkOverlapTokens, IDictionary serializedAdditionalRawData) + { + MaxChunkSizeTokens = maxChunkSizeTokens; + ChunkOverlapTokens = chunkOverlapTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreStaticChunkingStrategyOptions() + { + } + + /// The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. + public int MaxChunkSizeTokens { get; set; } + /// + /// The number of tokens that overlap between chunks. The default value is 400. + /// Note that the overlap must not exceed half of max_chunk_size_tokens. + /// + public int ChunkOverlapTokens { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs new file mode 100644 index 000000000000..a5b8553640dc --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreStaticChunkingStrategyRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyRequest)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("static"u8); + writer.WriteObjectValue(Static, options); + } + + VectorStoreStaticChunkingStrategyRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreStaticChunkingStrategyRequest(document.RootElement, options); + } + + internal static VectorStoreStaticChunkingStrategyRequest DeserializeVectorStoreStaticChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreStaticChunkingStrategyOptions @static = default; + VectorStoreChunkingStrategyRequestType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("static"u8)) + { + @static = VectorStoreStaticChunkingStrategyOptions.DeserializeVectorStoreStaticChunkingStrategyOptions(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyRequestType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreStaticChunkingStrategyRequest(type, serializedAdditionalRawData, @static); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyRequest)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreStaticChunkingStrategyRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreStaticChunkingStrategyRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new VectorStoreStaticChunkingStrategyRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreStaticChunkingStrategyRequest(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyRequest.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyRequest.cs new file mode 100644 index 000000000000..2459bf162fe5 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyRequest.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A statically configured chunking strategy. + public partial class VectorStoreStaticChunkingStrategyRequest : VectorStoreChunkingStrategyRequest + { + /// Initializes a new instance of . + /// The options for the static chunking strategy. + /// is null. + public VectorStoreStaticChunkingStrategyRequest(VectorStoreStaticChunkingStrategyOptions @static) + { + Argument.AssertNotNull(@static, nameof(@static)); + + Type = VectorStoreChunkingStrategyRequestType.Static; + Static = @static; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The options for the static chunking strategy. + internal VectorStoreStaticChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData, VectorStoreStaticChunkingStrategyOptions @static) : base(type, serializedAdditionalRawData) + { + Static = @static; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreStaticChunkingStrategyRequest() + { + } + + /// The options for the static chunking strategy. + public VectorStoreStaticChunkingStrategyOptions Static { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs new file mode 100644 index 000000000000..d21449b7b9ec --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Agents.Persistent +{ + public partial class VectorStoreStaticChunkingStrategyResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyResponse)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("static"u8); + writer.WriteObjectValue(Static, options); + } + + VectorStoreStaticChunkingStrategyResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreStaticChunkingStrategyResponse(document.RootElement, options); + } + + internal static VectorStoreStaticChunkingStrategyResponse DeserializeVectorStoreStaticChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreStaticChunkingStrategyOptions @static = default; + VectorStoreChunkingStrategyResponseType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("static"u8)) + { + @static = VectorStoreStaticChunkingStrategyOptions.DeserializeVectorStoreStaticChunkingStrategyOptions(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyResponseType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreStaticChunkingStrategyResponse(type, serializedAdditionalRawData, @static); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyResponse)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreStaticChunkingStrategyResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreStaticChunkingStrategyResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new VectorStoreStaticChunkingStrategyResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVectorStoreStaticChunkingStrategyResponse(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyResponse.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyResponse.cs new file mode 100644 index 000000000000..54cf0f752d45 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStaticChunkingStrategyResponse.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Agents.Persistent +{ + /// A statically configured chunking strategy. + public partial class VectorStoreStaticChunkingStrategyResponse : VectorStoreChunkingStrategyResponse + { + /// Initializes a new instance of . + /// The options for the static chunking strategy. + /// is null. + internal VectorStoreStaticChunkingStrategyResponse(VectorStoreStaticChunkingStrategyOptions @static) + { + Argument.AssertNotNull(@static, nameof(@static)); + + Type = VectorStoreChunkingStrategyResponseType.Static; + Static = @static; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The options for the static chunking strategy. + internal VectorStoreStaticChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData, VectorStoreStaticChunkingStrategyOptions @static) : base(type, serializedAdditionalRawData) + { + Static = @static; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreStaticChunkingStrategyResponse() + { + } + + /// The options for the static chunking strategy. + public VectorStoreStaticChunkingStrategyOptions Static { get; } + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStatus.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStatus.cs new file mode 100644 index 000000000000..f47385bfd399 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStoreStatus.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Agents.Persistent +{ + /// Vector store possible status. + public readonly partial struct VectorStoreStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ExpiredValue = "expired"; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + + /// expired status indicates that this vector store has expired and is no longer available for use. + public static VectorStoreStatus Expired { get; } = new VectorStoreStatus(ExpiredValue); + /// in_progress status indicates that this vector store is still processing files. + public static VectorStoreStatus InProgress { get; } = new VectorStoreStatus(InProgressValue); + /// completed status indicates that this vector store is ready for use. + public static VectorStoreStatus Completed { get; } = new VectorStoreStatus(CompletedValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreStatus left, VectorStoreStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreStatus left, VectorStoreStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VectorStoreStatus(string value) => new VectorStoreStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreStatus other && Equals(other); + /// + public bool Equals(VectorStoreStatus 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.Agents.Persistent/src/Generated/VectorStores.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStores.cs new file mode 100644 index 000000000000..7f5d8e7fa544 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Generated/VectorStores.cs @@ -0,0 +1,720 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.Agents.Persistent +{ + // Data plane generated sub-client. + /// A collection of vector-store operations under `/vector_stores`. + public partial class VectorStores + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of VectorStores for mocking. + protected VectorStores() + { + } + + /// Initializes a new instance of VectorStores. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. + /// Project endpoint in the form of: https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + /// The API version to use for this operation. + internal VectorStores(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Returns a list of vector 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 to use. + public virtual async Task> GetVectorStoresAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetVectorStoresAsync(limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfVectorStore.FromResponse(response), response); + } + + /// Returns a list of vector 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 to use. + public virtual Response GetVectorStores(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetVectorStores(limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfVectorStore.FromResponse(response), response); + } + + /// + /// [Protocol Method] Returns a list of vector stores. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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 async Task GetVectorStoresAsync(int? limit, string order, string after, string before, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("VectorStores.GetVectorStores"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVectorStoresRequest(limit, order, after, before, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Returns a list of vector stores. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// 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. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// 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 request context, 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 Response GetVectorStores(int? limit, string order, string after, string before, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("VectorStores.GetVectorStores"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVectorStoresRequest(limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates a vector store. + /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. + /// The name of the vector store. + /// The vector store configuration, used when vector store is created from Azure asset URIs. + /// Details on when this vector store expires. + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + public virtual async Task> CreateVectorStoreAsync(IEnumerable fileIds = null, string name = null, VectorStoreConfiguration storeConfiguration = null, VectorStoreExpirationPolicy expiresAfter = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + CreateVectorStoreRequest createVectorStoreRequest = new CreateVectorStoreRequest( + fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + name, + storeConfiguration, + expiresAfter, + chunkingStrategy, + metadata ?? new ChangeTrackingDictionary(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateVectorStoreAsync(createVectorStoreRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(VectorStore.FromResponse(response), response); + } + + /// Creates a vector store. + /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. + /// The name of the vector store. + /// The vector store configuration, used when vector store is created from Azure asset URIs. + /// Details on when this vector store expires. + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + public virtual Response CreateVectorStore(IEnumerable fileIds = null, string name = null, VectorStoreConfiguration storeConfiguration = null, VectorStoreExpirationPolicy expiresAfter = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + CreateVectorStoreRequest createVectorStoreRequest = new CreateVectorStoreRequest( + fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + name, + storeConfiguration, + expiresAfter, + chunkingStrategy, + metadata ?? new ChangeTrackingDictionary(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateVectorStore(createVectorStoreRequest.ToRequestContent(), context); + return Response.FromValue(VectorStore.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a vector store. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, 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 CreateVectorStoreAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("VectorStores.CreateVectorStore"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateVectorStoreRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a vector store. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, 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 Response CreateVectorStore(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("VectorStores.CreateVectorStore"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateVectorStoreRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Returns the vector store object matching the specified ID. + /// Identifier of the vector store. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetVectorStoreAsync(string vectorStoreId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetVectorStoreAsync(vectorStoreId, context).ConfigureAwait(false); + return Response.FromValue(VectorStore.FromResponse(response), response); + } + + /// Returns the vector store object matching the specified ID. + /// Identifier of the vector store. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetVectorStore(string vectorStoreId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetVectorStore(vectorStoreId, context); + return Response.FromValue(VectorStore.FromResponse(response), response); + } + + /// + /// [Protocol Method] Returns the vector store object matching the specified ID. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// The request context, 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 GetVectorStoreAsync(string vectorStoreId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStores.GetVectorStore"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVectorStoreRequest(vectorStoreId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Returns the vector store object matching the specified ID. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// The request context, 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 Response GetVectorStore(string vectorStoreId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStores.GetVectorStore"); + scope.Start(); + try + { + using HttpMessage message = CreateGetVectorStoreRequest(vectorStoreId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Modifies an existing vector store. + /// Identifier of the vector store. + /// The name of the vector store. + /// Details on when this vector store expires. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ModifyVectorStoreAsync(string vectorStoreId, string name = null, VectorStoreExpirationPolicy expiresAfter = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + ModifyVectorStoreRequest modifyVectorStoreRequest = new ModifyVectorStoreRequest(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await ModifyVectorStoreAsync(vectorStoreId, modifyVectorStoreRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(VectorStore.FromResponse(response), response); + } + + /// Modifies an existing vector store. + /// Identifier of the vector store. + /// The name of the vector store. + /// Details on when this vector store expires. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response ModifyVectorStore(string vectorStoreId, string name = null, VectorStoreExpirationPolicy expiresAfter = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + ModifyVectorStoreRequest modifyVectorStoreRequest = new ModifyVectorStoreRequest(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = ModifyVectorStore(vectorStoreId, modifyVectorStoreRequest.ToRequestContent(), context); + return Response.FromValue(VectorStore.FromResponse(response), response); + } + + /// + /// [Protocol Method] Modifies an existing vector store. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// The content to send as the body of the request. + /// The request context, 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 ModifyVectorStoreAsync(string vectorStoreId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("VectorStores.ModifyVectorStore"); + scope.Start(); + try + { + using HttpMessage message = CreateModifyVectorStoreRequest(vectorStoreId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Modifies an existing vector store. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// The content to send as the body of the request. + /// The request context, 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 Response ModifyVectorStore(string vectorStoreId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("VectorStores.ModifyVectorStore"); + scope.Start(); + try + { + using HttpMessage message = CreateModifyVectorStoreRequest(vectorStoreId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes the vector store object matching the specified ID. + /// Identifier of the vector store. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> DeleteVectorStoreAsync(string vectorStoreId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await DeleteVectorStoreAsync(vectorStoreId, context).ConfigureAwait(false); + return Response.FromValue(VectorStoreDeletionStatus.FromResponse(response), response); + } + + /// Deletes the vector store object matching the specified ID. + /// Identifier of the vector store. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response DeleteVectorStore(string vectorStoreId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = DeleteVectorStore(vectorStoreId, context); + return Response.FromValue(VectorStoreDeletionStatus.FromResponse(response), response); + } + + /// + /// [Protocol Method] Deletes the vector store object matching the specified ID. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// The request context, 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 DeleteVectorStoreAsync(string vectorStoreId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStores.DeleteVectorStore"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteVectorStoreRequest(vectorStoreId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Deletes the vector store object matching the specified ID. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Identifier of the vector store. + /// The request context, 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 Response DeleteVectorStore(string vectorStoreId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + using var scope = ClientDiagnostics.CreateScope("VectorStores.DeleteVectorStore"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteVectorStoreRequest(vectorStoreId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateVectorStoreRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetVectorStoreRequest(string vectorStoreId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateModifyVectorStoreRequest(string vectorStoreId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteVectorStoreRequest(string vectorStoreId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Properties/AssemblyInfo.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..4e51082df127 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.AI.Agents.Persistent.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/ai/Azure.AI.Agents.Persistent/tests/Azure.AI.Agents.Persistent.Tests.csproj b/sdk/ai/Azure.AI.Agents.Persistent/tests/Azure.AI.Agents.Persistent.Tests.csproj new file mode 100644 index 000000000000..66844b86f78e --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/tests/Azure.AI.Agents.Persistent.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/ai/Azure.AI.Agents.Persistent/tsp-location.yaml b/sdk/ai/Azure.AI.Agents.Persistent/tsp-location.yaml new file mode 100644 index 000000000000..079437cfc2c8 --- /dev/null +++ b/sdk/ai/Azure.AI.Agents.Persistent/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/ai/Azure.AI.Agents +commit: 645cb35500e38ca52eac5510483028093483c457 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/ai/ci.yml b/sdk/ai/ci.yml new file mode 100644 index 000000000000..142ed4e4567f --- /dev/null +++ b/sdk/ai/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/ai + - sdk/ai/ci.yml + - sdk/ai/Azure.AI.Agents.Persistent + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/ai + - sdk/ai/ci.yml + - sdk/ai/Azure.AI.Agents.Persistent + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: ai + ArtifactName: packages + Artifacts: + - name: Azure.AI.Agents.Persistent + safeName: AzureAIAgentsPersistent