From a0c0b76afe068954316b69659d808c653358ef98 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 12 Feb 2024 22:38:09 +0000 Subject: [PATCH] CodeGen from PR 27740 in Azure/azure-rest-api-specs Merge 313f00fac1da612c3e244d83755246b4aba43ad9 into 6e12137e69c1427ab45c4bab8cf98bd85503e4f2 --- .../tsp-location.yaml | 5 + ...AudioTranscriptionOptions.Serialization.cs | 4 +- ...AudioTranscriptionSegment.Serialization.cs | 12 +- .../AudioTranslationOptions.Serialization.cs | 4 +- .../AudioTranslationSegment.Serialization.cs | 12 +- ...eCognitiveSearchChatExtensionParameters.cs | 4 +- ...AzureCosmosDBChatExtensionConfiguration.cs | 2 +- ...DBChatExtensionParameters.Serialization.cs | 15 +- .../AzureCosmosDBChatExtensionParameters.cs | 26 +- ...smosDBFieldMappingOptions.Serialization.cs | 64 +- .../AzureCosmosDBFieldMappingOptions.cs | 29 +- ...ineLearningIndexChatExtensionParameters.cs | 4 +- .../src/Generated/AzureOpenAIModelFactory.cs | 16 + .../src/Generated/ChatChoice.Serialization.cs | 14 +- .../ChatCompletions.Serialization.cs | 4 +- ...ionsFunctionToolSelection.Serialization.cs | 136 + .../ChatCompletionsFunctionToolSelection.cs | 76 + ...amedFunctionToolSelection.Serialization.cs | 12 +- ...atCompletionsNamedFunctionToolSelection.cs | 20 +- .../ChatCompletionsOptions.Serialization.cs | 32 +- ...atMessageImageContentItem.Serialization.cs | 4 +- ...atRequestAssistantMessage.Serialization.cs | 8 +- .../ChatRequestToolMessage.Serialization.cs | 4 +- .../ChatResponseMessage.Serialization.cs | 8 +- .../src/Generated/Choice.Serialization.cs | 10 +- .../Generated/Completions.Serialization.cs | 2 +- ...etionsLogProbabilityModel.Serialization.cs | 12 +- .../CompletionsOptions.Serialization.cs | 24 +- .../CompletionsUsage.Serialization.cs | 12 +- ...ilterCitedDetectionResult.Serialization.cs | 4 +- ...terResultDetailsForPrompt.Serialization.cs | 8 +- ...entFilterResultsForChoice.Serialization.cs | 16 +- ...entFilterResultsForPrompt.Serialization.cs | 8 +- .../ElasticsearchChatExtensionParameters.cs | 4 +- .../EmbeddingsUsage.Serialization.cs | 8 +- .../ImageGenerationData.Serialization.cs | 14 +- .../ImageGenerationOptions.Serialization.cs | 4 +- ...okenAuthenticationOptions.Serialization.cs | 144 + ...ourDataAccessTokenAuthenticationOptions.cs | 45 + ...DataAuthenticationOptions.Serialization.cs | 2 + .../OnYourDataAuthenticationOptions.cs | 2 +- .../Generated/OnYourDataAuthenticationType.cs | 6 + ...iKeyAuthenticationOptions.Serialization.cs | 144 + ...rDataEncodedApiKeyAuthenticationOptions.cs | 45 + .../OnYourDataEndpointVectorizationSource.cs | 2 +- .../PineconeChatExtensionConfiguration.cs | 2 +- ...neChatExtensionParameters.Serialization.cs | 15 +- .../PineconeChatExtensionParameters.cs | 25 +- ...neconeFieldMappingOptions.Serialization.cs | 71 +- .../Generated/PineconeFieldMappingOptions.cs | 26 +- sdk/openai/Azure.AI.OpenAI/tsp-location.yaml | 6 +- .../Azure.AI.OpenAI.Assistants.sln | 56 + .../Azure.AI.OpenAI.Assistants/CHANGELOG.md | 11 + .../Directory.Build.props | 6 + .../Azure.AI.OpenAI.Assistants/README.md | 86 + .../src/Azure.AI.OpenAI.Assistants.csproj | 21 + ...OpenAIAssistantsClientBuilderExtensions.cs | 46 + .../AIOpenAIAssistantsModelFactory.cs | 317 ++ .../src/Generated/Assistant.Serialization.cs | 287 ++ .../src/Generated/Assistant.cs | 137 + .../AssistantCreationOptions.Serialization.cs | 288 ++ .../src/Generated/AssistantCreationOptions.cs | 107 + .../Generated/AssistantFile.Serialization.cs | 160 + .../src/Generated/AssistantFile.cs | 94 + .../src/Generated/AssistantFileObject.cs | 48 + .../src/Generated/AssistantObject.cs | 48 + .../AssistantThread.Serialization.cs | 183 + .../src/Generated/AssistantThread.cs | 93 + ...tantThreadCreationOptions.Serialization.cs | 186 + .../AssistantThreadCreationOptions.cs | 72 + .../src/Generated/AssistantThreadObject.cs | 48 + .../src/Generated/AssistantsClient.cs | 4193 +++++++++++++++++ .../src/Generated/AssistantsClientOptions.cs | 37 + ...InterpreterToolDefinition.Serialization.cs | 136 + .../CodeInterpreterToolDefinition.cs | 29 + ...CreateAndRunThreadOptions.Serialization.cs | 231 + .../Generated/CreateAndRunThreadOptions.cs | 102 + ...reateAssistantFileRequest.Serialization.cs | 136 + .../Generated/CreateAssistantFileRequest.cs | 76 + .../CreateMessageRequest.Serialization.cs | 202 + .../src/Generated/CreateMessageRequest.cs | 92 + .../CreateRunOptions.Serialization.cs | 270 ++ .../src/Generated/CreateRunOptions.cs | 108 + .../FunctionToolDefinition.Serialization.cs | 144 + .../src/Generated/FunctionToolDefinition.cs | 45 + ...alAssistantDeletionStatus.Serialization.cs | 152 + .../InternalAssistantDeletionStatus.cs | 86 + .../InternalAssistantDeletionStatusObject.cs | 48 + ...sistantFileDeletionStatus.Serialization.cs | 152 + .../InternalAssistantFileDeletionStatus.cs | 86 + ...ternalAssistantFileDeletionStatusObject.cs | 48 + ...nterpreterToolCallDetails.Serialization.cs | 154 + .../InternalCodeInterpreterToolCallDetails.cs | 88 + ...nternalFileDeletionStatus.Serialization.cs | 152 + .../Generated/InternalFileDeletionStatus.cs | 86 + .../InternalFileDeletionStatusObject.cs | 48 + .../InternalFileListResponse.Serialization.cs | 154 + .../src/Generated/InternalFileListResponse.cs | 82 + .../InternalFileListResponseObject.cs | 48 + ...nternalFunctionDefinition.Serialization.cs | 162 + .../Generated/InternalFunctionDefinition.cs | 116 + ...alMessageImageFileDetails.Serialization.cs | 136 + .../InternalMessageImageFileDetails.cs | 76 + ...MessageImageFileIdDetails.Serialization.cs | 136 + .../InternalMessageImageFileIdDetails.cs | 76 + ...nternalMessageTextDetails.Serialization.cs | 154 + .../Generated/InternalMessageTextDetails.cs | 88 + ...geTextFileCitationDetails.Serialization.cs | 144 + .../InternalMessageTextFileCitationDetails.cs | 83 + ...essageTextFilePathDetails.Serialization.cs | 136 + .../InternalMessageTextFilePathDetails.cs | 76 + ...edFunctionToolCallDetails.Serialization.cs | 144 + ...InternalRequiredFunctionToolCallDetails.cs | 83 + ...epFunctionToolCallDetails.Serialization.cs | 164 + .../InternalRunStepFunctionToolCallDetails.cs | 89 + ...lSubmitToolOutputsDetails.Serialization.cs | 146 + .../InternalSubmitToolOutputsDetails.cs | 81 + .../src/Generated/ListSortOrder.cs | 51 + .../Generated/MessageContent.Serialization.cs | 128 + .../src/Generated/MessageContent.cs | 69 + .../Generated/MessageFile.Serialization.cs | 160 + .../src/Generated/MessageFile.cs | 94 + .../src/Generated/MessageFileObject.cs | 48 + .../MessageImageFileContent.Serialization.cs | 144 + .../src/Generated/MessageImageFileContent.cs | 45 + .../src/Generated/MessageRole.cs | 51 + .../MessageTextAnnotation.Serialization.cs | 134 + .../src/Generated/MessageTextAnnotation.cs | 96 + .../MessageTextContent.Serialization.cs | 144 + .../src/Generated/MessageTextContent.cs | 45 + ...extFileCitationAnnotation.Serialization.cs | 168 + .../MessageTextFileCitationAnnotation.cs | 61 + ...ageTextFilePathAnnotation.Serialization.cs | 168 + .../MessageTextFilePathAnnotation.cs | 52 + .../src/Generated/OpenAIFile.Serialization.cs | 176 + .../src/Generated/OpenAIFile.cs | 106 + .../src/Generated/OpenAIFileObject.cs | 48 + .../src/Generated/OpenAIFilePurpose.cs | 57 + ...AIPageableListOfAssistant.Serialization.cs | 178 + .../OpenAIPageableListOfAssistant.cs | 102 + ...geableListOfAssistantFile.Serialization.cs | 178 + .../OpenAIPageableListOfAssistantFile.cs | 102 + ...OpenAIPageableListOfAssistantFileObject.cs | 48 + .../OpenAIPageableListOfAssistantObject.cs | 48 + ...PageableListOfMessageFile.Serialization.cs | 178 + .../OpenAIPageableListOfMessageFile.cs | 102 + .../OpenAIPageableListOfMessageFileObject.cs | 48 + ...enAIPageableListOfRunStep.Serialization.cs | 178 + .../Generated/OpenAIPageableListOfRunStep.cs | 102 + .../OpenAIPageableListOfRunStepObject.cs | 48 + ...geableListOfThreadMessage.Serialization.cs | 178 + .../OpenAIPageableListOfThreadMessage.cs | 102 + ...OpenAIPageableListOfThreadMessageObject.cs | 48 + ...AIPageableListOfThreadRun.Serialization.cs | 178 + .../OpenAIPageableListOfThreadRun.cs | 102 + .../OpenAIPageableListOfThreadRunObject.cs | 48 + .../Generated/RequiredAction.Serialization.cs | 127 + .../src/Generated/RequiredAction.cs | 69 + .../RequiredFunctionToolCall.Serialization.cs | 152 + .../src/Generated/RequiredFunctionToolCall.cs | 48 + .../RequiredToolCall.Serialization.cs | 129 + .../src/Generated/RequiredToolCall.cs | 84 + .../RetrievalToolDefinition.Serialization.cs | 136 + .../src/Generated/RetrievalToolDefinition.cs | 29 + .../src/Generated/RunError.Serialization.cs | 144 + .../src/Generated/RunError.cs | 83 + .../src/Generated/RunStatus.cs | 69 + .../src/Generated/RunStep.Serialization.cs | 331 ++ .../src/Generated/RunStep.cs | 167 + ...odeInterpreterImageOutput.Serialization.cs | 144 + .../RunStepCodeInterpreterImageOutput.cs | 45 + ...InterpreterImageReference.Serialization.cs | 136 + .../RunStepCodeInterpreterImageReference.cs | 76 + ...pCodeInterpreterLogOutput.Serialization.cs | 144 + .../RunStepCodeInterpreterLogOutput.cs | 45 + ...epCodeInterpreterToolCall.Serialization.cs | 152 + .../RunStepCodeInterpreterToolCall.cs | 51 + ...InterpreterToolCallOutput.Serialization.cs | 128 + .../RunStepCodeInterpreterToolCallOutput.cs | 69 + .../Generated/RunStepDetails.Serialization.cs | 128 + .../src/Generated/RunStepDetails.cs | 69 + .../Generated/RunStepError.Serialization.cs | 144 + .../src/Generated/RunStepError.cs | 82 + .../src/Generated/RunStepErrorCode.cs | 51 + .../RunStepFunctionToolCall.Serialization.cs | 152 + .../src/Generated/RunStepFunctionToolCall.cs | 51 + ...tepMessageCreationDetails.Serialization.cs | 144 + .../RunStepMessageCreationDetails.cs | 45 + ...pMessageCreationReference.Serialization.cs | 136 + .../RunStepMessageCreationReference.cs | 76 + .../src/Generated/RunStepObject.cs | 48 + .../RunStepRetrievalToolCall.Serialization.cs | 163 + .../src/Generated/RunStepRetrievalToolCall.cs | 51 + .../src/Generated/RunStepStatus.cs | 60 + .../RunStepToolCall.Serialization.cs | 131 + .../src/Generated/RunStepToolCall.cs | 84 + .../RunStepToolCallDetails.Serialization.cs | 154 + .../src/Generated/RunStepToolCallDetails.cs | 50 + .../src/Generated/RunStepType.cs | 51 + .../SubmitToolOutputsAction.Serialization.cs | 144 + .../src/Generated/SubmitToolOutputsAction.cs | 45 + ...itToolOutputsToRunRequest.Serialization.cs | 146 + .../SubmitToolOutputsToRunRequest.cs | 77 + .../ThreadDeletionStatus.Serialization.cs | 152 + .../src/Generated/ThreadDeletionStatus.cs | 86 + .../Generated/ThreadDeletionStatusObject.cs | 48 + ...readInitializationMessage.Serialization.cs | 202 + .../Generated/ThreadInitializationMessage.cs | 98 + .../Generated/ThreadMessage.Serialization.cs | 257 + .../src/Generated/ThreadMessage.cs | 142 + .../src/Generated/ThreadMessageObject.cs | 48 + .../src/Generated/ThreadRun.Serialization.cs | 402 ++ .../src/Generated/ThreadRun.cs | 190 + .../src/Generated/ThreadRunObject.cs | 48 + .../Generated/ToolDefinition.Serialization.cs | 129 + .../src/Generated/ToolDefinition.cs | 69 + .../src/Generated/ToolOutput.Serialization.cs | 150 + .../src/Generated/ToolOutput.cs | 69 + .../UnknownMessageContent.Serialization.cs | 136 + .../src/Generated/UnknownMessageContent.cs | 28 + ...nownMessageTextAnnotation.Serialization.cs | 160 + .../Generated/UnknownMessageTextAnnotation.cs | 31 + .../UnknownRequiredAction.Serialization.cs | 136 + .../src/Generated/UnknownRequiredAction.cs | 28 + .../UnknownRequiredToolCall.Serialization.cs | 144 + .../src/Generated/UnknownRequiredToolCall.cs | 29 + ...InterpreterToolCallOutput.Serialization.cs | 136 + ...ownRunStepCodeInterpreterToolCallOutput.cs | 28 + .../UnknownRunStepDetails.Serialization.cs | 136 + .../src/Generated/UnknownRunStepDetails.cs | 28 + .../UnknownRunStepToolCall.Serialization.cs | 144 + .../src/Generated/UnknownRunStepToolCall.cs | 29 + .../UnknownToolDefinition.Serialization.cs | 136 + .../src/Generated/UnknownToolDefinition.cs | 28 + .../UpdateAssistantOptions.Serialization.cs | 291 ++ .../src/Generated/UpdateAssistantOptions.cs | 97 + .../UpdateMessageRequest.Serialization.cs | 161 + .../src/Generated/UpdateMessageRequest.cs | 67 + .../UpdateRunRequest.Serialization.cs | 161 + .../src/Generated/UpdateRunRequest.cs | 67 + .../UpdateThreadRequest.Serialization.cs | 161 + .../src/Generated/UpdateThreadRequest.cs | 67 + .../UploadFileRequest.Serialization.cs | 155 + .../src/Generated/UploadFileRequest.cs | 101 + .../src/Properties/AssemblyInfo.cs | 11 + .../Azure.AI.OpenAI.Assistants.Tests.csproj | 20 + .../tsp-location.yaml | 5 + sdk/openai/assistants/ci.yml | 35 + .../ImageAnalysisResult.Serialization.cs | 58 +- .../ImageBoundingBox.Serialization.cs | 18 +- .../tsp-location.yaml | 7 +- 251 files changed, 26235 insertions(+), 292 deletions(-) create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml create mode 100644 sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsFunctionToolSelection.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsFunctionToolSelection.cs create mode 100644 sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAccessTokenAuthenticationOptions.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAccessTokenAuthenticationOptions.cs create mode 100644 sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEncodedApiKeyAuthenticationOptions.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEncodedApiKeyAuthenticationOptions.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/Azure.AI.OpenAI.Assistants.sln create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/CHANGELOG.md create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/Directory.Build.props create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/README.md create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Azure.AI.OpenAI.Assistants.csproj create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AIOpenAIAssistantsClientBuilderExtensions.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AIOpenAIAssistantsModelFactory.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFileObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClientOptions.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolDefinition.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolDefinition.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/FunctionToolDefinition.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/FunctionToolDefinition.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatus.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatus.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatusObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatusObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalCodeInterpreterToolCallDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatus.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatus.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatusObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponse.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponse.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponseObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFunctionDefinition.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFunctionDefinition.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileIdDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileIdDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRequiredFunctionToolCallDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRequiredFunctionToolCallDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRunStepFunctionToolCallDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRunStepFunctionToolCallDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalSubmitToolOutputsDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ListSortOrder.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageContent.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageContent.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFileObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageRole.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFileObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFilePurpose.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistant.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistant.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFile.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFile.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFileObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFile.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFile.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFileObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStep.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStep.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStepObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessage.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessage.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessageObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRun.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRun.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRunObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredAction.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredAction.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredFunctionToolCall.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredFunctionToolCall.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredToolCall.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredToolCall.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunError.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunError.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStatus.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageOutput.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageOutput.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageReference.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageReference.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterLogOutput.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterLogOutput.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCall.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCall.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCallOutput.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepError.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepError.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepErrorCode.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFunctionToolCall.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFunctionToolCall.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationReference.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationReference.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepStatus.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepType.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsAction.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsAction.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatus.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatus.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatusObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessageObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRunObject.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolOutput.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolOutput.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageContent.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageContent.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredAction.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredAction.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredToolCall.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredToolCall.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDetails.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDetails.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepToolCall.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepToolCall.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownToolDefinition.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownToolDefinition.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateMessageRequest.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateMessageRequest.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateRunRequest.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateRunRequest.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UploadFileRequest.Serialization.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UploadFileRequest.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Properties/AssemblyInfo.cs create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/tests/Azure.AI.OpenAI.Assistants.Tests.csproj create mode 100644 sdk/openai/assistants/Azure.AI.OpenAI.Assistants/tsp-location.yaml create mode 100644 sdk/openai/assistants/ci.yml diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml b/sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml new file mode 100644 index 0000000000000..44fdfaaad7e60 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml @@ -0,0 +1,5 @@ +repo: Azure/azure-rest-api-specs +directory: specification/loadtestservice/LoadTestService +commit: a718913e51a489e2ed6fa6a5966e5291b8018435 +additionalDirectories: [] + diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptions.Serialization.cs index c15cdd7968772..2c403ef8cf518 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptions.Serialization.cs @@ -36,7 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea } if (Optional.IsDefined(ResponseFormat)) { - writer.WritePropertyName("response_format"u8); + writer.WritePropertyName("responseFormat"u8); writer.WriteStringValue(ResponseFormat.Value.ToString()); } if (Optional.IsDefined(Language)) @@ -118,7 +118,7 @@ internal static AudioTranscriptionOptions DeserializeAudioTranscriptionOptions(J filename = property.Value.GetString(); continue; } - if (property.NameEquals("response_format"u8)) + if (property.NameEquals("responseFormat"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSegment.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSegment.Serialization.cs index a5df1b9d496b0..f3b7782a53c78 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSegment.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSegment.Serialization.cs @@ -37,11 +37,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea writer.WriteStringValue(Text); writer.WritePropertyName("temperature"u8); writer.WriteNumberValue(Temperature); - writer.WritePropertyName("avg_logprob"u8); + writer.WritePropertyName("avgLogprob"u8); writer.WriteNumberValue(AverageLogProbability); - writer.WritePropertyName("compression_ratio"u8); + writer.WritePropertyName("compressionRatio"u8); writer.WriteNumberValue(CompressionRatio); - writer.WritePropertyName("no_speech_prob"u8); + writer.WritePropertyName("noSpeechProb"u8); writer.WriteNumberValue(NoSpeechProbability); writer.WritePropertyName("tokens"u8); writer.WriteStartArray(); @@ -129,17 +129,17 @@ internal static AudioTranscriptionSegment DeserializeAudioTranscriptionSegment(J temperature = property.Value.GetSingle(); continue; } - if (property.NameEquals("avg_logprob"u8)) + if (property.NameEquals("avgLogprob"u8)) { avgLogprob = property.Value.GetSingle(); continue; } - if (property.NameEquals("compression_ratio"u8)) + if (property.NameEquals("compressionRatio"u8)) { compressionRatio = property.Value.GetSingle(); continue; } - if (property.NameEquals("no_speech_prob"u8)) + if (property.NameEquals("noSpeechProb"u8)) { noSpeechProb = property.Value.GetSingle(); continue; diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptions.Serialization.cs index ca8ab42e88c79..f560d563e02c1 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptions.Serialization.cs @@ -36,7 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade } if (Optional.IsDefined(ResponseFormat)) { - writer.WritePropertyName("response_format"u8); + writer.WritePropertyName("responseFormat"u8); writer.WriteStringValue(ResponseFormat.Value.ToString()); } if (Optional.IsDefined(Prompt)) @@ -112,7 +112,7 @@ internal static AudioTranslationOptions DeserializeAudioTranslationOptions(JsonE filename = property.Value.GetString(); continue; } - if (property.NameEquals("response_format"u8)) + if (property.NameEquals("responseFormat"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationSegment.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationSegment.Serialization.cs index 0b2b78602b9ae..515146b57b5b0 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationSegment.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationSegment.Serialization.cs @@ -37,11 +37,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade writer.WriteStringValue(Text); writer.WritePropertyName("temperature"u8); writer.WriteNumberValue(Temperature); - writer.WritePropertyName("avg_logprob"u8); + writer.WritePropertyName("avgLogprob"u8); writer.WriteNumberValue(AverageLogProbability); - writer.WritePropertyName("compression_ratio"u8); + writer.WritePropertyName("compressionRatio"u8); writer.WriteNumberValue(CompressionRatio); - writer.WritePropertyName("no_speech_prob"u8); + writer.WritePropertyName("noSpeechProb"u8); writer.WriteNumberValue(NoSpeechProbability); writer.WritePropertyName("tokens"u8); writer.WriteStartArray(); @@ -129,17 +129,17 @@ internal static AudioTranslationSegment DeserializeAudioTranslationSegment(JsonE temperature = property.Value.GetSingle(); continue; } - if (property.NameEquals("avg_logprob"u8)) + if (property.NameEquals("avgLogprob"u8)) { avgLogprob = property.Value.GetSingle(); continue; } - if (property.NameEquals("compression_ratio"u8)) + if (property.NameEquals("compressionRatio"u8)) { compressionRatio = property.Value.GetSingle(); continue; } - if (property.NameEquals("no_speech_prob"u8)) + if (property.NameEquals("noSpeechProb"u8)) { noSpeechProb = property.Value.GetSingle(); continue; diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCognitiveSearchChatExtensionParameters.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCognitiveSearchChatExtensionParameters.cs index 20e752cd96be4..6b1015f193b18 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCognitiveSearchChatExtensionParameters.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCognitiveSearchChatExtensionParameters.cs @@ -11,7 +11,7 @@ namespace Azure.AI.OpenAI { - /// Parameters for Azure Cognitive Search when used as an Azure OpenAI chat extension. + /// Parameters for Azure Cognitive Search when used as an Azure OpenAI chat extension. The supported authentication types are APIKey, SystemAssignedManagedIdentity and UserAssignedManagedIdentity. internal partial class AzureCognitiveSearchChatExtensionParameters { /// @@ -96,7 +96,7 @@ internal AzureCognitiveSearchChatExtensionParameters(OnYourDataAuthenticationOpt /// If not otherwise provided, On Your Data will attempt to use System Managed Identity (default credential) /// authentication. /// 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 available derived classes include , , , , , and . /// public OnYourDataAuthenticationOptions Authentication { get; set; } /// The configured top number of documents to feature for the configured query. diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionConfiguration.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionConfiguration.cs index 926298684fa5f..82d888dc00764 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionConfiguration.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionConfiguration.cs @@ -12,7 +12,7 @@ namespace Azure.AI.OpenAI { /// - /// A specific representation of configurable options for Elasticsearch when using it as an Azure OpenAI chat + /// A specific representation of configurable options for Azure Cosmos DB when using it as an Azure OpenAI chat /// extension. /// public partial class AzureCosmosDBChatExtensionConfiguration : AzureChatExtensionConfiguration diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionParameters.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionParameters.Serialization.cs index 16cf0c74284fc..f7785ce911840 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionParameters.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionParameters.Serialization.cs @@ -60,11 +60,8 @@ void IJsonModel.Write(Utf8JsonWriter write writer.WriteStringValue(IndexName); writer.WritePropertyName("fieldsMapping"u8); writer.WriteObjectValue(FieldMappingOptions); - if (Optional.IsDefined(EmbeddingDependency)) - { - writer.WritePropertyName("embeddingDependency"u8); - writer.WriteObjectValue(EmbeddingDependency); - } + writer.WritePropertyName("embeddingDependency"u8); + writer.WriteObjectValue(EmbeddingDependency); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -112,7 +109,7 @@ internal static AzureCosmosDBChatExtensionParameters DeserializeAzureCosmosDBCha string containerName = default; string indexName = default; AzureCosmosDBFieldMappingOptions fieldsMapping = default; - Optional embeddingDependency = default; + OnYourDataVectorizationSource embeddingDependency = default; IDictionary serializedAdditionalRawData = default; Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -180,10 +177,6 @@ internal static AzureCosmosDBChatExtensionParameters DeserializeAzureCosmosDBCha } if (property.NameEquals("embeddingDependency"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } embeddingDependency = OnYourDataVectorizationSource.DeserializeOnYourDataVectorizationSource(property.Value); continue; } @@ -193,7 +186,7 @@ internal static AzureCosmosDBChatExtensionParameters DeserializeAzureCosmosDBCha } } serializedAdditionalRawData = additionalPropertiesDictionary; - return new AzureCosmosDBChatExtensionParameters(authentication.Value, Optional.ToNullable(topNDocuments), Optional.ToNullable(inScope), Optional.ToNullable(strictness), roleInformation.Value, databaseName, containerName, indexName, fieldsMapping, embeddingDependency.Value, serializedAdditionalRawData); + return new AzureCosmosDBChatExtensionParameters(authentication.Value, Optional.ToNullable(topNDocuments), Optional.ToNullable(inScope), Optional.ToNullable(strictness), roleInformation.Value, databaseName, containerName, indexName, fieldsMapping, embeddingDependency, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionParameters.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionParameters.cs index 40b5b2e216c6b..38790a298c462 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionParameters.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBChatExtensionParameters.cs @@ -13,7 +13,7 @@ namespace Azure.AI.OpenAI { /// /// Parameters to use when configuring Azure OpenAI On Your Data chat extensions when using Azure Cosmos DB for - /// MongoDB vCore. + /// MongoDB vCore. The supported authentication type is ConnectionString. /// internal partial class AzureCosmosDBChatExtensionParameters { @@ -49,6 +49,28 @@ internal partial class AzureCosmosDBChatExtensionParameters /// private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . + /// The MongoDB vCore database name to use with Azure Cosmos DB. + /// The name of the Azure Cosmos DB resource container. + /// The MongoDB vCore index name to use with Azure Cosmos DB. + /// Customized field mapping behavior to use when interacting with the search index. + /// The embedding dependency for vector search. + /// , , , or is null. + public AzureCosmosDBChatExtensionParameters(string databaseName, string containerName, string indexName, AzureCosmosDBFieldMappingOptions fieldMappingOptions, OnYourDataVectorizationSource embeddingDependency) + { + Argument.AssertNotNull(databaseName, nameof(databaseName)); + Argument.AssertNotNull(containerName, nameof(containerName)); + Argument.AssertNotNull(indexName, nameof(indexName)); + Argument.AssertNotNull(fieldMappingOptions, nameof(fieldMappingOptions)); + Argument.AssertNotNull(embeddingDependency, nameof(embeddingDependency)); + + DatabaseName = databaseName; + ContainerName = containerName; + IndexName = indexName; + FieldMappingOptions = fieldMappingOptions; + EmbeddingDependency = embeddingDependency; + } + /// Initializes a new instance of . /// /// The authentication method to use when accessing the defined data source. @@ -89,7 +111,7 @@ internal AzureCosmosDBChatExtensionParameters(OnYourDataAuthenticationOptions au /// If not otherwise provided, On Your Data will attempt to use System Managed Identity (default credential) /// authentication. /// 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 available derived classes include , , , , , and . /// public OnYourDataAuthenticationOptions Authentication { get; set; } /// The configured top number of documents to feature for the configured query. diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBFieldMappingOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBFieldMappingOptions.Serialization.cs index 3beba15532c01..f3014596cd3b8 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBFieldMappingOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBFieldMappingOptions.Serialization.cs @@ -27,6 +27,33 @@ void IJsonModel.Write(Utf8JsonWriter writer, M } writer.WriteStartObject(); + if (Optional.IsDefined(TitleFieldName)) + { + writer.WritePropertyName("titleField"u8); + writer.WriteStringValue(TitleFieldName); + } + if (Optional.IsDefined(UrlFieldName)) + { + writer.WritePropertyName("urlField"u8); + writer.WriteStringValue(UrlFieldName); + } + if (Optional.IsDefined(FilepathFieldName)) + { + writer.WritePropertyName("filepathField"u8); + writer.WriteStringValue(FilepathFieldName); + } + writer.WritePropertyName("contentFields"u8); + writer.WriteStartArray(); + foreach (var item in ContentFieldNames) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(ContentFieldSeparator)) + { + writer.WritePropertyName("contentFieldsSeparator"u8); + writer.WriteStringValue(ContentFieldSeparator); + } writer.WritePropertyName("vectorFields"u8); writer.WriteStartArray(); foreach (var item in VectorFieldNames) @@ -72,11 +99,46 @@ internal static AzureCosmosDBFieldMappingOptions DeserializeAzureCosmosDBFieldMa { return null; } + Optional titleField = default; + Optional urlField = default; + Optional filepathField = default; + IList contentFields = default; + Optional contentFieldsSeparator = default; IList vectorFields = default; IDictionary serializedAdditionalRawData = default; Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { + if (property.NameEquals("titleField"u8)) + { + titleField = property.Value.GetString(); + continue; + } + if (property.NameEquals("urlField"u8)) + { + urlField = property.Value.GetString(); + continue; + } + if (property.NameEquals("filepathField"u8)) + { + filepathField = property.Value.GetString(); + continue; + } + if (property.NameEquals("contentFields"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + contentFields = array; + continue; + } + if (property.NameEquals("contentFieldsSeparator"u8)) + { + contentFieldsSeparator = property.Value.GetString(); + continue; + } if (property.NameEquals("vectorFields"u8)) { List array = new List(); @@ -93,7 +155,7 @@ internal static AzureCosmosDBFieldMappingOptions DeserializeAzureCosmosDBFieldMa } } serializedAdditionalRawData = additionalPropertiesDictionary; - return new AzureCosmosDBFieldMappingOptions(vectorFields, serializedAdditionalRawData); + return new AzureCosmosDBFieldMappingOptions(titleField.Value, urlField.Value, filepathField.Value, contentFields, contentFieldsSeparator.Value, vectorFields, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBFieldMappingOptions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBFieldMappingOptions.cs index be0737add2920..91544ea4daf57 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBFieldMappingOptions.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureCosmosDBFieldMappingOptions.cs @@ -48,20 +48,33 @@ public partial class AzureCosmosDBFieldMappingOptions private IDictionary _serializedAdditionalRawData; /// Initializes a new instance of . + /// The names of index fields that should be treated as content. /// The names of fields that represent vector data. - /// is null. - public AzureCosmosDBFieldMappingOptions(IEnumerable vectorFieldNames) + /// or is null. + public AzureCosmosDBFieldMappingOptions(IEnumerable contentFieldNames, IEnumerable vectorFieldNames) { + Argument.AssertNotNull(contentFieldNames, nameof(contentFieldNames)); Argument.AssertNotNull(vectorFieldNames, nameof(vectorFieldNames)); + ContentFieldNames = contentFieldNames.ToList(); VectorFieldNames = vectorFieldNames.ToList(); } /// Initializes a new instance of . + /// The name of the index field to use as a title. + /// The name of the index field to use as a URL. + /// The name of the index field to use as a filepath. + /// The names of index fields that should be treated as content. + /// The separator pattern that content fields should use. /// The names of fields that represent vector data. /// Keeps track of any properties unknown to the library. - internal AzureCosmosDBFieldMappingOptions(IList vectorFieldNames, IDictionary serializedAdditionalRawData) + internal AzureCosmosDBFieldMappingOptions(string titleFieldName, string urlFieldName, string filepathFieldName, IList contentFieldNames, string contentFieldSeparator, IList vectorFieldNames, IDictionary serializedAdditionalRawData) { + TitleFieldName = titleFieldName; + UrlFieldName = urlFieldName; + FilepathFieldName = filepathFieldName; + ContentFieldNames = contentFieldNames; + ContentFieldSeparator = contentFieldSeparator; VectorFieldNames = vectorFieldNames; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -71,6 +84,16 @@ internal AzureCosmosDBFieldMappingOptions() { } + /// The name of the index field to use as a title. + public string TitleFieldName { get; set; } + /// The name of the index field to use as a URL. + public string UrlFieldName { get; set; } + /// The name of the index field to use as a filepath. + public string FilepathFieldName { get; set; } + /// The names of index fields that should be treated as content. + public IList ContentFieldNames { get; } + /// The separator pattern that content fields should use. + public string ContentFieldSeparator { get; set; } /// The names of fields that represent vector data. public IList VectorFieldNames { get; } } diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureMachineLearningIndexChatExtensionParameters.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureMachineLearningIndexChatExtensionParameters.cs index 99f5d09a583a2..c279df3f5f87f 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureMachineLearningIndexChatExtensionParameters.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureMachineLearningIndexChatExtensionParameters.cs @@ -11,7 +11,7 @@ namespace Azure.AI.OpenAI { - /// Parameters for the Azure Machine Learning vector index chat extension. + /// Parameters for the Azure Machine Learning vector index chat extension. The supported authentication types are AccessToken, SystemAssignedManagedIdentity and UserAssignedManagedIdentity. internal partial class AzureMachineLearningIndexChatExtensionParameters { /// @@ -84,7 +84,7 @@ internal AzureMachineLearningIndexChatExtensionParameters(OnYourDataAuthenticati /// If not otherwise provided, On Your Data will attempt to use System Managed Identity (default credential) /// authentication. /// 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 available derived classes include , , , , , and . /// public OnYourDataAuthenticationOptions Authentication { get; set; } /// The configured top number of documents to feature for the configured query. diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs index ea5bc15cd5cae..c7cacfce6370e 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs @@ -535,6 +535,22 @@ public static OnYourDataKeyAndKeyIdAuthenticationOptions OnYourDataKeyAndKeyIdAu return new OnYourDataKeyAndKeyIdAuthenticationOptions(OnYourDataAuthenticationType.KeyAndKeyId, serializedAdditionalRawData: null, key, keyId); } + /// Initializes a new instance of . + /// The encoded API key to use for authentication. + /// A new instance for mocking. + public static OnYourDataEncodedApiKeyAuthenticationOptions OnYourDataEncodedApiKeyAuthenticationOptions(string encodedApiKey = null) + { + return new OnYourDataEncodedApiKeyAuthenticationOptions(OnYourDataAuthenticationType.EncodedApiKey, serializedAdditionalRawData: null, encodedApiKey); + } + + /// Initializes a new instance of . + /// The access token to use for authentication. + /// A new instance for mocking. + public static OnYourDataAccessTokenAuthenticationOptions OnYourDataAccessTokenAuthenticationOptions(string accessToken = null) + { + return new OnYourDataAccessTokenAuthenticationOptions(OnYourDataAuthenticationType.AccessToken, serializedAdditionalRawData: null, accessToken); + } + /// Initializes a new instance of . /// The resource ID of the user-assigned managed identity to use for authentication. /// A new instance for mocking. diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.Serialization.cs index 4f5a00c8149b8..4278eae23abd9 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.Serialization.cs @@ -36,16 +36,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOption writer.WriteNumberValue(Index); if (FinishReason != null) { - writer.WritePropertyName("finish_reason"u8); + writer.WritePropertyName("finishReason"u8); writer.WriteStringValue(FinishReason.Value.ToString()); } else { - writer.WriteNull("finish_reason"); + writer.WriteNull("finishReason"); } if (Optional.IsDefined(FinishDetails)) { - writer.WritePropertyName("finish_details"u8); + writer.WritePropertyName("finishDetails"u8); writer.WriteObjectValue(FinishDetails); } if (Optional.IsDefined(InternalStreamingDeltaMessage)) @@ -55,7 +55,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOption } if (Optional.IsDefined(ContentFilterResults)) { - writer.WritePropertyName("content_filter_results"u8); + writer.WritePropertyName("contentFilterResults"u8); writer.WriteObjectValue(ContentFilterResults); } if (Optional.IsDefined(Enhancements)) @@ -126,7 +126,7 @@ internal static ChatChoice DeserializeChatChoice(JsonElement element, ModelReade index = property.Value.GetInt32(); continue; } - if (property.NameEquals("finish_reason"u8)) + if (property.NameEquals("finishReason"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -136,7 +136,7 @@ internal static ChatChoice DeserializeChatChoice(JsonElement element, ModelReade finishReason = new CompletionsFinishReason(property.Value.GetString()); continue; } - if (property.NameEquals("finish_details"u8)) + if (property.NameEquals("finishDetails"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -154,7 +154,7 @@ internal static ChatChoice DeserializeChatChoice(JsonElement element, ModelReade delta = ChatResponseMessage.DeserializeChatResponseMessage(property.Value); continue; } - if (property.NameEquals("content_filter_results"u8)) + if (property.NameEquals("contentFilterResults"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.Serialization.cs index 11d4a1e597bf5..3b2f51f6d2a27 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.Serialization.cs @@ -39,7 +39,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO writer.WriteEndArray(); if (Optional.IsCollectionDefined(PromptFilterResults)) { - writer.WritePropertyName("prompt_filter_results"u8); + writer.WritePropertyName("promptFilterResults"u8); writer.WriteStartArray(); foreach (var item in PromptFilterResults) { @@ -49,7 +49,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO } if (Optional.IsDefined(SystemFingerprint)) { - writer.WritePropertyName("system_fingerprint"u8); + writer.WritePropertyName("systemFingerprint"u8); writer.WriteStringValue(SystemFingerprint); } writer.WritePropertyName("usage"u8); diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsFunctionToolSelection.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsFunctionToolSelection.Serialization.cs new file mode 100644 index 0000000000000..f7e6f8adfeb1a --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsFunctionToolSelection.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + internal partial class ChatCompletionsFunctionToolSelection : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatCompletionsFunctionToolSelection)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ChatCompletionsFunctionToolSelection 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(ChatCompletionsFunctionToolSelection)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatCompletionsFunctionToolSelection(document.RootElement, options); + } + + internal static ChatCompletionsFunctionToolSelection DeserializeChatCompletionsFunctionToolSelection(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ChatCompletionsFunctionToolSelection(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(ChatCompletionsFunctionToolSelection)} does not support '{options.Format}' format."); + } + } + + ChatCompletionsFunctionToolSelection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatCompletionsFunctionToolSelection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatCompletionsFunctionToolSelection)} does not support '{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 ChatCompletionsFunctionToolSelection FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatCompletionsFunctionToolSelection(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsFunctionToolSelection.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsFunctionToolSelection.cs new file mode 100644 index 0000000000000..2fde1515815a7 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsFunctionToolSelection.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; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// A tool selection of a specific, named function tool that will limit chat completions to using the named function. + internal partial class ChatCompletionsFunctionToolSelection + { + /// + /// 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 that should be called. + /// is null. + public ChatCompletionsFunctionToolSelection(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + /// Initializes a new instance of . + /// The name of the function that should be called. + /// Keeps track of any properties unknown to the library. + internal ChatCompletionsFunctionToolSelection(string name, IDictionary serializedAdditionalRawData) + { + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ChatCompletionsFunctionToolSelection() + { + } + + /// The name of the function that should be called. + public string Name { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsNamedFunctionToolSelection.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsNamedFunctionToolSelection.Serialization.cs index 65951b6403ef0..c16643f70ab42 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsNamedFunctionToolSelection.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsNamedFunctionToolSelection.Serialization.cs @@ -27,8 +27,8 @@ void IJsonModel.Write(Utf8JsonWriter } writer.WriteStartObject(); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function); writer.WritePropertyName("type"u8); writer.WriteStringValue(Type); if (options.Format != "W" && _serializedAdditionalRawData != null) @@ -69,15 +69,15 @@ internal static ChatCompletionsNamedFunctionToolSelection DeserializeChatComplet { return null; } - string name = default; + ChatCompletionsFunctionToolSelection function = default; string type = default; IDictionary serializedAdditionalRawData = default; Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (property.NameEquals("function"u8)) { - name = property.Value.GetString(); + function = ChatCompletionsFunctionToolSelection.DeserializeChatCompletionsFunctionToolSelection(property.Value); continue; } if (property.NameEquals("type"u8)) @@ -91,7 +91,7 @@ internal static ChatCompletionsNamedFunctionToolSelection DeserializeChatComplet } } serializedAdditionalRawData = additionalPropertiesDictionary; - return new ChatCompletionsNamedFunctionToolSelection(type, serializedAdditionalRawData, name); + return new ChatCompletionsNamedFunctionToolSelection(type, serializedAdditionalRawData, function); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsNamedFunctionToolSelection.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsNamedFunctionToolSelection.cs index 4946847d0ad6b..d6ae5b22f5093 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsNamedFunctionToolSelection.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsNamedFunctionToolSelection.cs @@ -15,23 +15,23 @@ namespace Azure.AI.OpenAI internal partial class ChatCompletionsNamedFunctionToolSelection : ChatCompletionsNamedToolSelection { /// Initializes a new instance of . - /// The name of the function that should be called. - /// is null. - public ChatCompletionsNamedFunctionToolSelection(string name) + /// The function that should be called. + /// is null. + public ChatCompletionsNamedFunctionToolSelection(ChatCompletionsFunctionToolSelection function) { - Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(function, nameof(function)); Type = "function"; - Name = name; + Function = function; } /// Initializes a new instance of . /// The object type. /// Keeps track of any properties unknown to the library. - /// The name of the function that should be called. - internal ChatCompletionsNamedFunctionToolSelection(string type, IDictionary serializedAdditionalRawData, string name) : base(type, serializedAdditionalRawData) + /// The function that should be called. + internal ChatCompletionsNamedFunctionToolSelection(string type, IDictionary serializedAdditionalRawData, ChatCompletionsFunctionToolSelection function) : base(type, serializedAdditionalRawData) { - Name = name; + Function = function; } /// Initializes a new instance of for deserialization. @@ -39,7 +39,7 @@ internal ChatCompletionsNamedFunctionToolSelection() { } - /// The name of the function that should be called. - public string Name { get; } + /// The function that should be called. + public ChatCompletionsFunctionToolSelection Function { get; } } } diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsOptions.Serialization.cs index 9c0ad6fad43af..12bdb9a61832b 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsOptions.Serialization.cs @@ -44,12 +44,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader } if (Optional.IsDefined(FunctionCall)) { - writer.WritePropertyName("function_call"u8); + writer.WritePropertyName("functionCall"u8); writer.WriteObjectValue(FunctionCall); } if (Optional.IsDefined(MaxTokens)) { - writer.WritePropertyName("max_tokens"u8); + writer.WritePropertyName("maxTokens"u8); writer.WriteNumberValue(MaxTokens.Value); } if (Optional.IsDefined(Temperature)) @@ -59,12 +59,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader } if (Optional.IsDefined(NucleusSamplingFactor)) { - writer.WritePropertyName("top_p"u8); + writer.WritePropertyName("topP"u8); writer.WriteNumberValue(NucleusSamplingFactor.Value); } if (Optional.IsCollectionDefined(TokenSelectionBiases)) { - writer.WritePropertyName("logit_bias"u8); + writer.WritePropertyName("logitBias"u8); SerializeTokenSelectionBiases(writer); } if (Optional.IsDefined(User)) @@ -89,12 +89,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader } if (Optional.IsDefined(PresencePenalty)) { - writer.WritePropertyName("presence_penalty"u8); + writer.WritePropertyName("presencePenalty"u8); writer.WriteNumberValue(PresencePenalty.Value); } if (Optional.IsDefined(FrequencyPenalty)) { - writer.WritePropertyName("frequency_penalty"u8); + writer.WritePropertyName("frequencyPenalty"u8); writer.WriteNumberValue(FrequencyPenalty.Value); } if (Optional.IsDefined(InternalShouldStreamResponse)) @@ -129,7 +129,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader } if (Optional.IsDefined(ResponseFormat)) { - writer.WritePropertyName("response_format"u8); + writer.WritePropertyName("responseFormat"u8); writer.WriteObjectValue(ResponseFormat); } if (Optional.IsCollectionDefined(Tools)) @@ -144,7 +144,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader } if (Optional.IsDefined(InternalSuppressedToolChoice)) { - writer.WritePropertyName("tool_choice"u8); + writer.WritePropertyName("toolChoice"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(InternalSuppressedToolChoice); #else @@ -240,7 +240,7 @@ internal static ChatCompletionsOptions DeserializeChatCompletionsOptions(JsonEle functions = array; continue; } - if (property.NameEquals("function_call"u8)) + if (property.NameEquals("functionCall"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -249,7 +249,7 @@ internal static ChatCompletionsOptions DeserializeChatCompletionsOptions(JsonEle functionCall = FunctionDefinition.DeserializeFunctionDefinition(property.Value); continue; } - if (property.NameEquals("max_tokens"u8)) + if (property.NameEquals("maxTokens"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -267,7 +267,7 @@ internal static ChatCompletionsOptions DeserializeChatCompletionsOptions(JsonEle temperature = property.Value.GetSingle(); continue; } - if (property.NameEquals("top_p"u8)) + if (property.NameEquals("topP"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -276,7 +276,7 @@ internal static ChatCompletionsOptions DeserializeChatCompletionsOptions(JsonEle topP = property.Value.GetSingle(); continue; } - if (property.NameEquals("logit_bias"u8)) + if (property.NameEquals("logitBias"u8)) { DeserializeTokenSelectionBiases(property, ref logitBias); continue; @@ -309,7 +309,7 @@ internal static ChatCompletionsOptions DeserializeChatCompletionsOptions(JsonEle stop = array; continue; } - if (property.NameEquals("presence_penalty"u8)) + if (property.NameEquals("presencePenalty"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -318,7 +318,7 @@ internal static ChatCompletionsOptions DeserializeChatCompletionsOptions(JsonEle presencePenalty = property.Value.GetSingle(); continue; } - if (property.NameEquals("frequency_penalty"u8)) + if (property.NameEquals("frequencyPenalty"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -373,7 +373,7 @@ internal static ChatCompletionsOptions DeserializeChatCompletionsOptions(JsonEle seed = property.Value.GetInt64(); continue; } - if (property.NameEquals("response_format"u8)) + if (property.NameEquals("responseFormat"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -396,7 +396,7 @@ internal static ChatCompletionsOptions DeserializeChatCompletionsOptions(JsonEle tools = array; continue; } - if (property.NameEquals("tool_choice"u8)) + if (property.NameEquals("toolChoice"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessageImageContentItem.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessageImageContentItem.Serialization.cs index 322ceaba2f69b..d1cefd2b02067 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessageImageContentItem.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessageImageContentItem.Serialization.cs @@ -27,7 +27,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR } writer.WriteStartObject(); - writer.WritePropertyName("image_url"u8); + writer.WritePropertyName("imageUrl"u8); writer.WriteObjectValue(ImageUrl); writer.WritePropertyName("type"u8); writer.WriteStringValue(Type); @@ -75,7 +75,7 @@ internal static ChatMessageImageContentItem DeserializeChatMessageImageContentIt Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("image_url"u8)) + if (property.NameEquals("imageUrl"u8)) { imageUrl = ChatMessageImageUrl.DeserializeChatMessageImageUrl(property.Value); continue; diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRequestAssistantMessage.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRequestAssistantMessage.Serialization.cs index da30349b39f35..88b0a6c0a8404 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRequestAssistantMessage.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRequestAssistantMessage.Serialization.cs @@ -43,7 +43,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR } if (Optional.IsCollectionDefined(ToolCalls)) { - writer.WritePropertyName("tool_calls"u8); + writer.WritePropertyName("toolCalls"u8); writer.WriteStartArray(); foreach (var item in ToolCalls) { @@ -53,7 +53,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR } if (Optional.IsDefined(FunctionCall)) { - writer.WritePropertyName("function_call"u8); + writer.WritePropertyName("functionCall"u8); writer.WriteObjectValue(FunctionCall); } writer.WritePropertyName("role"u8); @@ -120,7 +120,7 @@ internal static ChatRequestAssistantMessage DeserializeChatRequestAssistantMessa name = property.Value.GetString(); continue; } - if (property.NameEquals("tool_calls"u8)) + if (property.NameEquals("toolCalls"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -134,7 +134,7 @@ internal static ChatRequestAssistantMessage DeserializeChatRequestAssistantMessa toolCalls = array; continue; } - if (property.NameEquals("function_call"u8)) + if (property.NameEquals("functionCall"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRequestToolMessage.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRequestToolMessage.Serialization.cs index a198459a9406c..67d6b93d88bae 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRequestToolMessage.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRequestToolMessage.Serialization.cs @@ -36,7 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader { writer.WriteNull("content"); } - writer.WritePropertyName("tool_call_id"u8); + writer.WritePropertyName("toolCallId"u8); writer.WriteStringValue(ToolCallId); writer.WritePropertyName("role"u8); writer.WriteStringValue(Role.ToString()); @@ -95,7 +95,7 @@ internal static ChatRequestToolMessage DeserializeChatRequestToolMessage(JsonEle content = property.Value.GetString(); continue; } - if (property.NameEquals("tool_call_id"u8)) + if (property.NameEquals("toolCallId"u8)) { toolCallId = property.Value.GetString(); continue; diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatResponseMessage.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatResponseMessage.Serialization.cs index 7931024848756..e43565f24d4a6 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatResponseMessage.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatResponseMessage.Serialization.cs @@ -40,7 +40,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri } if (Optional.IsCollectionDefined(ToolCalls)) { - writer.WritePropertyName("tool_calls"u8); + writer.WritePropertyName("toolCalls"u8); writer.WriteStartArray(); foreach (var item in ToolCalls) { @@ -50,7 +50,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri } if (Optional.IsDefined(FunctionCall)) { - writer.WritePropertyName("function_call"u8); + writer.WritePropertyName("functionCall"u8); writer.WriteObjectValue(FunctionCall); } if (Optional.IsDefined(AzureExtensionsContext)) @@ -120,7 +120,7 @@ internal static ChatResponseMessage DeserializeChatResponseMessage(JsonElement e content = property.Value.GetString(); continue; } - if (property.NameEquals("tool_calls"u8)) + if (property.NameEquals("toolCalls"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -134,7 +134,7 @@ internal static ChatResponseMessage DeserializeChatResponseMessage(JsonElement e toolCalls = array; continue; } - if (property.NameEquals("function_call"u8)) + if (property.NameEquals("functionCall"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.Serialization.cs index d8ed144cbd736..1e0d00cd28f20 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.Serialization.cs @@ -33,7 +33,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions op writer.WriteNumberValue(Index); if (Optional.IsDefined(ContentFilterResults)) { - writer.WritePropertyName("content_filter_results"u8); + writer.WritePropertyName("contentFilterResults"u8); writer.WriteObjectValue(ContentFilterResults); } if (LogProbabilityModel != null) @@ -47,12 +47,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions op } if (FinishReason != null) { - writer.WritePropertyName("finish_reason"u8); + writer.WritePropertyName("finishReason"u8); writer.WriteStringValue(FinishReason.Value.ToString()); } else { - writer.WriteNull("finish_reason"); + writer.WriteNull("finishReason"); } if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -111,7 +111,7 @@ internal static Choice DeserializeChoice(JsonElement element, ModelReaderWriterO index = property.Value.GetInt32(); continue; } - if (property.NameEquals("content_filter_results"u8)) + if (property.NameEquals("contentFilterResults"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -130,7 +130,7 @@ internal static Choice DeserializeChoice(JsonElement element, ModelReaderWriterO logprobs = CompletionsLogProbabilityModel.DeserializeCompletionsLogProbabilityModel(property.Value); continue; } - if (property.NameEquals("finish_reason"u8)) + if (property.NameEquals("finishReason"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.Serialization.cs index d5c797d92fad9..9ce56336e0fb4 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.Serialization.cs @@ -32,7 +32,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio writer.WriteNumberValue(Created, "U"); if (Optional.IsCollectionDefined(PromptFilterResults)) { - writer.WritePropertyName("prompt_filter_results"u8); + writer.WritePropertyName("promptFilterResults"u8); writer.WriteStartArray(); foreach (var item in PromptFilterResults) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsLogProbabilityModel.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsLogProbabilityModel.Serialization.cs index 846fd490ce939..8d26536583778 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsLogProbabilityModel.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsLogProbabilityModel.Serialization.cs @@ -34,7 +34,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod writer.WriteStringValue(item); } writer.WriteEndArray(); - writer.WritePropertyName("token_logprobs"u8); + writer.WritePropertyName("tokenLogprobs"u8); writer.WriteStartArray(); foreach (var item in TokenLogProbabilities) { @@ -46,7 +46,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod writer.WriteNumberValue(item.Value); } writer.WriteEndArray(); - writer.WritePropertyName("top_logprobs"u8); + writer.WritePropertyName("topLogprobs"u8); writer.WriteStartArray(); foreach (var item in TopLogProbabilities) { @@ -69,7 +69,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod writer.WriteEndObject(); } writer.WriteEndArray(); - writer.WritePropertyName("text_offset"u8); + writer.WritePropertyName("textOffset"u8); writer.WriteStartArray(); foreach (var item in TextOffsets) { @@ -132,7 +132,7 @@ internal static CompletionsLogProbabilityModel DeserializeCompletionsLogProbabil tokens = array; continue; } - if (property.NameEquals("token_logprobs"u8)) + if (property.NameEquals("tokenLogprobs"u8)) { List array = new List(); foreach (var item in property.Value.EnumerateArray()) @@ -149,7 +149,7 @@ internal static CompletionsLogProbabilityModel DeserializeCompletionsLogProbabil tokenLogprobs = array; continue; } - if (property.NameEquals("top_logprobs"u8)) + if (property.NameEquals("topLogprobs"u8)) { List> array = new List>(); foreach (var item in property.Value.EnumerateArray()) @@ -178,7 +178,7 @@ internal static CompletionsLogProbabilityModel DeserializeCompletionsLogProbabil topLogprobs = array; continue; } - if (property.NameEquals("text_offset"u8)) + if (property.NameEquals("textOffset"u8)) { List array = new List(); foreach (var item in property.Value.EnumerateArray()) diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsOptions.Serialization.cs index d1ac7801a1600..b9366d5e00fd7 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsOptions.Serialization.cs @@ -36,7 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit writer.WriteEndArray(); if (Optional.IsDefined(MaxTokens)) { - writer.WritePropertyName("max_tokens"u8); + writer.WritePropertyName("maxTokens"u8); writer.WriteNumberValue(MaxTokens.Value); } if (Optional.IsDefined(Temperature)) @@ -46,12 +46,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsDefined(NucleusSamplingFactor)) { - writer.WritePropertyName("top_p"u8); + writer.WritePropertyName("topP"u8); writer.WriteNumberValue(NucleusSamplingFactor.Value); } if (Optional.IsCollectionDefined(TokenSelectionBiases)) { - writer.WritePropertyName("logit_bias"u8); + writer.WritePropertyName("logitBias"u8); SerializeTokenSelectionBiases(writer); } if (Optional.IsDefined(User)) @@ -86,17 +86,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit } if (Optional.IsDefined(PresencePenalty)) { - writer.WritePropertyName("presence_penalty"u8); + writer.WritePropertyName("presencePenalty"u8); writer.WriteNumberValue(PresencePenalty.Value); } if (Optional.IsDefined(FrequencyPenalty)) { - writer.WritePropertyName("frequency_penalty"u8); + writer.WritePropertyName("frequencyPenalty"u8); writer.WriteNumberValue(FrequencyPenalty.Value); } if (Optional.IsDefined(GenerationSampleCount)) { - writer.WritePropertyName("best_of"u8); + writer.WritePropertyName("bestOf"u8); writer.WriteNumberValue(GenerationSampleCount.Value); } if (Optional.IsDefined(InternalShouldStreamResponse)) @@ -176,7 +176,7 @@ internal static CompletionsOptions DeserializeCompletionsOptions(JsonElement ele prompt = array; continue; } - if (property.NameEquals("max_tokens"u8)) + if (property.NameEquals("maxTokens"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -194,7 +194,7 @@ internal static CompletionsOptions DeserializeCompletionsOptions(JsonElement ele temperature = property.Value.GetSingle(); continue; } - if (property.NameEquals("top_p"u8)) + if (property.NameEquals("topP"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -203,7 +203,7 @@ internal static CompletionsOptions DeserializeCompletionsOptions(JsonElement ele topP = property.Value.GetSingle(); continue; } - if (property.NameEquals("logit_bias"u8)) + if (property.NameEquals("logitBias"u8)) { DeserializeTokenSelectionBiases(property, ref logitBias); continue; @@ -254,7 +254,7 @@ internal static CompletionsOptions DeserializeCompletionsOptions(JsonElement ele stop = array; continue; } - if (property.NameEquals("presence_penalty"u8)) + if (property.NameEquals("presencePenalty"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -263,7 +263,7 @@ internal static CompletionsOptions DeserializeCompletionsOptions(JsonElement ele presencePenalty = property.Value.GetSingle(); continue; } - if (property.NameEquals("frequency_penalty"u8)) + if (property.NameEquals("frequencyPenalty"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -272,7 +272,7 @@ internal static CompletionsOptions DeserializeCompletionsOptions(JsonElement ele frequencyPenalty = property.Value.GetSingle(); continue; } - if (property.NameEquals("best_of"u8)) + if (property.NameEquals("bestOf"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsUsage.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsUsage.Serialization.cs index a0599a2955467..5874f2e32bc42 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsUsage.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsUsage.Serialization.cs @@ -27,11 +27,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter } writer.WriteStartObject(); - writer.WritePropertyName("completion_tokens"u8); + writer.WritePropertyName("completionTokens"u8); writer.WriteNumberValue(CompletionTokens); - writer.WritePropertyName("prompt_tokens"u8); + writer.WritePropertyName("promptTokens"u8); writer.WriteNumberValue(PromptTokens); - writer.WritePropertyName("total_tokens"u8); + writer.WritePropertyName("totalTokens"u8); writer.WriteNumberValue(TotalTokens); if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -78,17 +78,17 @@ internal static CompletionsUsage DeserializeCompletionsUsage(JsonElement element Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("completion_tokens"u8)) + if (property.NameEquals("completionTokens"u8)) { completionTokens = property.Value.GetInt32(); continue; } - if (property.NameEquals("prompt_tokens"u8)) + if (property.NameEquals("promptTokens"u8)) { promptTokens = property.Value.GetInt32(); continue; } - if (property.NameEquals("total_tokens"u8)) + if (property.NameEquals("totalTokens"u8)) { totalTokens = property.Value.GetInt32(); continue; diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterCitedDetectionResult.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterCitedDetectionResult.Serialization.cs index 4881ef3747aa5..385b5ac8d6991 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterCitedDetectionResult.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterCitedDetectionResult.Serialization.cs @@ -33,7 +33,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, writer.WriteBooleanValue(Detected); if (Optional.IsDefined(Url)) { - writer.WritePropertyName("URL"u8); + writer.WritePropertyName("url"u8); writer.WriteStringValue(Url.AbsoluteUri); } writer.WritePropertyName("license"u8); @@ -94,7 +94,7 @@ internal static ContentFilterCitedDetectionResult DeserializeContentFilterCitedD detected = property.Value.GetBoolean(); continue; } - if (property.NameEquals("URL"u8)) + if (property.NameEquals("url"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultDetailsForPrompt.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultDetailsForPrompt.Serialization.cs index 8f37b5bb4cdad..310d390f1b32f 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultDetailsForPrompt.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultDetailsForPrompt.Serialization.cs @@ -44,7 +44,7 @@ void IJsonModel.Write(Utf8JsonWriter writer } if (Optional.IsDefined(SelfHarm)) { - writer.WritePropertyName("self_harm"u8); + writer.WritePropertyName("selfHarm"u8); writer.WriteObjectValue(SelfHarm); } if (Optional.IsDefined(Profanity)) @@ -54,7 +54,7 @@ void IJsonModel.Write(Utf8JsonWriter writer } if (Optional.IsCollectionDefined(CustomBlocklists)) { - writer.WritePropertyName("custom_blocklists"u8); + writer.WritePropertyName("customBlocklists"u8); writer.WriteStartArray(); foreach (var item in CustomBlocklists) { @@ -149,7 +149,7 @@ internal static ContentFilterResultDetailsForPrompt DeserializeContentFilterResu hate = ContentFilterResult.DeserializeContentFilterResult(property.Value); continue; } - if (property.NameEquals("self_harm"u8)) + if (property.NameEquals("selfHarm"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -167,7 +167,7 @@ internal static ContentFilterResultDetailsForPrompt DeserializeContentFilterResu profanity = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(property.Value); continue; } - if (property.NameEquals("custom_blocklists"u8)) + if (property.NameEquals("customBlocklists"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultsForChoice.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultsForChoice.Serialization.cs index 881efbb57ffa0..ed71a4ec56361 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultsForChoice.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultsForChoice.Serialization.cs @@ -44,7 +44,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode } if (Optional.IsDefined(SelfHarm)) { - writer.WritePropertyName("self_harm"u8); + writer.WritePropertyName("selfHarm"u8); writer.WriteObjectValue(SelfHarm); } if (Optional.IsDefined(Profanity)) @@ -54,7 +54,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode } if (Optional.IsCollectionDefined(CustomBlocklists)) { - writer.WritePropertyName("custom_blocklists"u8); + writer.WritePropertyName("customBlocklists"u8); writer.WriteStartArray(); foreach (var item in CustomBlocklists) { @@ -69,12 +69,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode } if (Optional.IsDefined(ProtectedMaterialText)) { - writer.WritePropertyName("protected_material_text"u8); + writer.WritePropertyName("protectedMaterialText"u8); writer.WriteObjectValue(ProtectedMaterialText); } if (Optional.IsDefined(ProtectedMaterialCode)) { - writer.WritePropertyName("protected_material_code"u8); + writer.WritePropertyName("protectedMaterialCode"u8); writer.WriteObjectValue(ProtectedMaterialCode); } if (options.Format != "W" && _serializedAdditionalRawData != null) @@ -155,7 +155,7 @@ internal static ContentFilterResultsForChoice DeserializeContentFilterResultsFor hate = ContentFilterResult.DeserializeContentFilterResult(property.Value); continue; } - if (property.NameEquals("self_harm"u8)) + if (property.NameEquals("selfHarm"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -173,7 +173,7 @@ internal static ContentFilterResultsForChoice DeserializeContentFilterResultsFor profanity = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(property.Value); continue; } - if (property.NameEquals("custom_blocklists"u8)) + if (property.NameEquals("customBlocklists"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -196,7 +196,7 @@ internal static ContentFilterResultsForChoice DeserializeContentFilterResultsFor error = JsonSerializer.Deserialize(property.Value.GetRawText()); continue; } - if (property.NameEquals("protected_material_text"u8)) + if (property.NameEquals("protectedMaterialText"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { @@ -205,7 +205,7 @@ internal static ContentFilterResultsForChoice DeserializeContentFilterResultsFor protectedMaterialText = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(property.Value); continue; } - if (property.NameEquals("protected_material_code"u8)) + if (property.NameEquals("protectedMaterialCode"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultsForPrompt.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultsForPrompt.Serialization.cs index cc32c1eab358b..cc8d354745a4b 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultsForPrompt.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResultsForPrompt.Serialization.cs @@ -27,9 +27,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode } writer.WriteStartObject(); - writer.WritePropertyName("prompt_index"u8); + writer.WritePropertyName("promptIndex"u8); writer.WriteNumberValue(PromptIndex); - writer.WritePropertyName("content_filter_results"u8); + writer.WritePropertyName("contentFilterResults"u8); writer.WriteObjectValue(ContentFilterResults); if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -75,12 +75,12 @@ internal static ContentFilterResultsForPrompt DeserializeContentFilterResultsFor Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("prompt_index"u8)) + if (property.NameEquals("promptIndex"u8)) { promptIndex = property.Value.GetInt32(); continue; } - if (property.NameEquals("content_filter_results"u8)) + if (property.NameEquals("contentFilterResults"u8)) { contentFilterResults = ContentFilterResultDetailsForPrompt.DeserializeContentFilterResultDetailsForPrompt(property.Value); continue; diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ElasticsearchChatExtensionParameters.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ElasticsearchChatExtensionParameters.cs index 97de60e80ee50..dc3848cd6d822 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ElasticsearchChatExtensionParameters.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ElasticsearchChatExtensionParameters.cs @@ -11,7 +11,7 @@ namespace Azure.AI.OpenAI { - /// Parameters to use when configuring Elasticsearch® as an Azure OpenAI chat extension. + /// Parameters to use when configuring Elasticsearch® as an Azure OpenAI chat extension. The supported authentication types are KeyAndKeyId and EncodedAPIKey. internal partial class ElasticsearchChatExtensionParameters { /// @@ -86,7 +86,7 @@ internal ElasticsearchChatExtensionParameters(OnYourDataAuthenticationOptions au /// If not otherwise provided, On Your Data will attempt to use System Managed Identity (default credential) /// authentication. /// 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 available derived classes include , , , , , and . /// public OnYourDataAuthenticationOptions Authentication { get; set; } /// The configured top number of documents to feature for the configured query. diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/EmbeddingsUsage.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/EmbeddingsUsage.Serialization.cs index 6b80e76ffa02f..e13be7cba77be 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/EmbeddingsUsage.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/EmbeddingsUsage.Serialization.cs @@ -27,9 +27,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO } writer.WriteStartObject(); - writer.WritePropertyName("prompt_tokens"u8); + writer.WritePropertyName("promptTokens"u8); writer.WriteNumberValue(PromptTokens); - writer.WritePropertyName("total_tokens"u8); + writer.WritePropertyName("totalTokens"u8); writer.WriteNumberValue(TotalTokens); if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -75,12 +75,12 @@ internal static EmbeddingsUsage DeserializeEmbeddingsUsage(JsonElement element, Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("prompt_tokens"u8)) + if (property.NameEquals("promptTokens"u8)) { promptTokens = property.Value.GetInt32(); continue; } - if (property.NameEquals("total_tokens"u8)) + if (property.NameEquals("totalTokens"u8)) { totalTokens = property.Value.GetInt32(); continue; diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationData.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationData.Serialization.cs index ba1fd35a8e26d..311ccda856d4d 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationData.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationData.Serialization.cs @@ -34,12 +34,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri } if (Optional.IsDefined(Base64Data)) { - writer.WritePropertyName("b64_json"u8); + writer.WritePropertyName("base64Data"u8); writer.WriteStringValue(Base64Data); } if (Optional.IsDefined(RevisedPrompt)) { - writer.WritePropertyName("revised_prompt"u8); + writer.WritePropertyName("revisedPrompt"u8); writer.WriteStringValue(RevisedPrompt); } if (options.Format != "W" && _serializedAdditionalRawData != null) @@ -81,7 +81,7 @@ internal static ImageGenerationData DeserializeImageGenerationData(JsonElement e return null; } Optional url = default; - Optional b64Json = default; + Optional base64Data = default; Optional revisedPrompt = default; IDictionary serializedAdditionalRawData = default; Dictionary additionalPropertiesDictionary = new Dictionary(); @@ -96,12 +96,12 @@ internal static ImageGenerationData DeserializeImageGenerationData(JsonElement e url = new Uri(property.Value.GetString()); continue; } - if (property.NameEquals("b64_json"u8)) + if (property.NameEquals("base64Data"u8)) { - b64Json = property.Value.GetString(); + base64Data = property.Value.GetString(); continue; } - if (property.NameEquals("revised_prompt"u8)) + if (property.NameEquals("revisedPrompt"u8)) { revisedPrompt = property.Value.GetString(); continue; @@ -112,7 +112,7 @@ internal static ImageGenerationData DeserializeImageGenerationData(JsonElement e } } serializedAdditionalRawData = additionalPropertiesDictionary; - return new ImageGenerationData(url.Value, b64Json.Value, revisedPrompt.Value, serializedAdditionalRawData); + return new ImageGenerationData(url.Value, base64Data.Value, revisedPrompt.Value, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs index 8e539281fb5a0..37ea035456f76 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs @@ -46,7 +46,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader } if (Optional.IsDefined(ResponseFormat)) { - writer.WritePropertyName("response_format"u8); + writer.WritePropertyName("responseFormat"u8); writer.WriteStringValue(ResponseFormat.Value.ToString()); } if (Optional.IsDefined(Quality)) @@ -142,7 +142,7 @@ internal static ImageGenerationOptions DeserializeImageGenerationOptions(JsonEle size = new ImageSize(property.Value.GetString()); continue; } - if (property.NameEquals("response_format"u8)) + if (property.NameEquals("responseFormat"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAccessTokenAuthenticationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAccessTokenAuthenticationOptions.Serialization.cs new file mode 100644 index 0000000000000..36237e34a6282 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAccessTokenAuthenticationOptions.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; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + public partial class OnYourDataAccessTokenAuthenticationOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OnYourDataAccessTokenAuthenticationOptions)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("accessToken"u8); + writer.WriteStringValue(AccessToken); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OnYourDataAccessTokenAuthenticationOptions 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(OnYourDataAccessTokenAuthenticationOptions)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOnYourDataAccessTokenAuthenticationOptions(document.RootElement, options); + } + + internal static OnYourDataAccessTokenAuthenticationOptions DeserializeOnYourDataAccessTokenAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string accessToken = default; + OnYourDataAuthenticationType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("accessToken"u8)) + { + accessToken = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new OnYourDataAuthenticationType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new OnYourDataAccessTokenAuthenticationOptions(type, serializedAdditionalRawData, accessToken); + } + + 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(OnYourDataAccessTokenAuthenticationOptions)} does not support '{options.Format}' format."); + } + } + + OnYourDataAccessTokenAuthenticationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOnYourDataAccessTokenAuthenticationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OnYourDataAccessTokenAuthenticationOptions)} does not support '{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 OnYourDataAccessTokenAuthenticationOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOnYourDataAccessTokenAuthenticationOptions(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAccessTokenAuthenticationOptions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAccessTokenAuthenticationOptions.cs new file mode 100644 index 0000000000000..a1353b0da588f --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAccessTokenAuthenticationOptions.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// The authentication options for Azure OpenAI On Your Data when using access token. + public partial class OnYourDataAccessTokenAuthenticationOptions : OnYourDataAuthenticationOptions + { + /// Initializes a new instance of . + /// The access token to use for authentication. + /// is null. + public OnYourDataAccessTokenAuthenticationOptions(string accessToken) + { + Argument.AssertNotNull(accessToken, nameof(accessToken)); + + Type = OnYourDataAuthenticationType.AccessToken; + AccessToken = accessToken; + } + + /// Initializes a new instance of . + /// The authentication type. + /// Keeps track of any properties unknown to the library. + /// The access token to use for authentication. + internal OnYourDataAccessTokenAuthenticationOptions(OnYourDataAuthenticationType type, IDictionary serializedAdditionalRawData, string accessToken) : base(type, serializedAdditionalRawData) + { + AccessToken = accessToken; + } + + /// Initializes a new instance of for deserialization. + internal OnYourDataAccessTokenAuthenticationOptions() + { + } + + /// The access token to use for authentication. + public string AccessToken { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationOptions.Serialization.cs index 0a01dd472de3a..879917fb5a512 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationOptions.Serialization.cs @@ -74,6 +74,8 @@ internal static OnYourDataAuthenticationOptions DeserializeOnYourDataAuthenticat case "APIKey": return OnYourDataApiKeyAuthenticationOptions.DeserializeOnYourDataApiKeyAuthenticationOptions(element); case "ConnectionString": return OnYourDataConnectionStringAuthenticationOptions.DeserializeOnYourDataConnectionStringAuthenticationOptions(element); case "KeyAndKeyId": return OnYourDataKeyAndKeyIdAuthenticationOptions.DeserializeOnYourDataKeyAndKeyIdAuthenticationOptions(element); + case "EncodedAPIKey": return OnYourDataEncodedApiKeyAuthenticationOptions.DeserializeOnYourDataEncodedApiKeyAuthenticationOptions(element); + case "AccessToken": return OnYourDataAccessTokenAuthenticationOptions.DeserializeOnYourDataAccessTokenAuthenticationOptions(element); case "SystemAssignedManagedIdentity": return OnYourDataSystemAssignedManagedIdentityAuthenticationOptions.DeserializeOnYourDataSystemAssignedManagedIdentityAuthenticationOptions(element); case "UserAssignedManagedIdentity": return OnYourDataUserAssignedManagedIdentityAuthenticationOptions.DeserializeOnYourDataUserAssignedManagedIdentityAuthenticationOptions(element); } diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationOptions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationOptions.cs index 41c84b1b8c5a9..03a596b1dff79 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationOptions.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationOptions.cs @@ -13,7 +13,7 @@ namespace Azure.AI.OpenAI /// /// The authentication options for Azure OpenAI On Your Data. /// 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 available derived classes include , , , , , and . /// public abstract partial class OnYourDataAuthenticationOptions { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationType.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationType.cs index 318433a35a298..bc5147a51b8d9 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationType.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataAuthenticationType.cs @@ -25,6 +25,8 @@ public OnYourDataAuthenticationType(string value) private const string ApiKeyValue = "APIKey"; private const string ConnectionStringValue = "ConnectionString"; private const string KeyAndKeyIdValue = "KeyAndKeyId"; + private const string EncodedApiKeyValue = "EncodedAPIKey"; + private const string AccessTokenValue = "AccessToken"; private const string SystemAssignedManagedIdentityValue = "SystemAssignedManagedIdentity"; private const string UserAssignedManagedIdentityValue = "UserAssignedManagedIdentity"; @@ -34,6 +36,10 @@ public OnYourDataAuthenticationType(string value) public static OnYourDataAuthenticationType ConnectionString { get; } = new OnYourDataAuthenticationType(ConnectionStringValue); /// Authentication via key and key ID pair. public static OnYourDataAuthenticationType KeyAndKeyId { get; } = new OnYourDataAuthenticationType(KeyAndKeyIdValue); + /// Authentication via encoded API key. + public static OnYourDataAuthenticationType EncodedApiKey { get; } = new OnYourDataAuthenticationType(EncodedApiKeyValue); + /// Authentication via access token. + public static OnYourDataAuthenticationType AccessToken { get; } = new OnYourDataAuthenticationType(AccessTokenValue); /// Authentication via system-assigned managed identity. public static OnYourDataAuthenticationType SystemAssignedManagedIdentity { get; } = new OnYourDataAuthenticationType(SystemAssignedManagedIdentityValue); /// Authentication via user-assigned managed identity. diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEncodedApiKeyAuthenticationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEncodedApiKeyAuthenticationOptions.Serialization.cs new file mode 100644 index 0000000000000..e7f35d0979bb6 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEncodedApiKeyAuthenticationOptions.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; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + public partial class OnYourDataEncodedApiKeyAuthenticationOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OnYourDataEncodedApiKeyAuthenticationOptions)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("encodedApiKey"u8); + writer.WriteStringValue(EncodedApiKey); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OnYourDataEncodedApiKeyAuthenticationOptions 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(OnYourDataEncodedApiKeyAuthenticationOptions)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOnYourDataEncodedApiKeyAuthenticationOptions(document.RootElement, options); + } + + internal static OnYourDataEncodedApiKeyAuthenticationOptions DeserializeOnYourDataEncodedApiKeyAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string encodedApiKey = default; + OnYourDataAuthenticationType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("encodedApiKey"u8)) + { + encodedApiKey = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new OnYourDataAuthenticationType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new OnYourDataEncodedApiKeyAuthenticationOptions(type, serializedAdditionalRawData, encodedApiKey); + } + + 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(OnYourDataEncodedApiKeyAuthenticationOptions)} does not support '{options.Format}' format."); + } + } + + OnYourDataEncodedApiKeyAuthenticationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOnYourDataEncodedApiKeyAuthenticationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OnYourDataEncodedApiKeyAuthenticationOptions)} does not support '{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 OnYourDataEncodedApiKeyAuthenticationOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOnYourDataEncodedApiKeyAuthenticationOptions(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEncodedApiKeyAuthenticationOptions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEncodedApiKeyAuthenticationOptions.cs new file mode 100644 index 0000000000000..d4ea138f72439 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEncodedApiKeyAuthenticationOptions.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// The authentication options for Azure OpenAI On Your Data when using an Elasticsearch encoded API key. + public partial class OnYourDataEncodedApiKeyAuthenticationOptions : OnYourDataAuthenticationOptions + { + /// Initializes a new instance of . + /// The encoded API key to use for authentication. + /// is null. + public OnYourDataEncodedApiKeyAuthenticationOptions(string encodedApiKey) + { + Argument.AssertNotNull(encodedApiKey, nameof(encodedApiKey)); + + Type = OnYourDataAuthenticationType.EncodedApiKey; + EncodedApiKey = encodedApiKey; + } + + /// Initializes a new instance of . + /// The authentication type. + /// Keeps track of any properties unknown to the library. + /// The encoded API key to use for authentication. + internal OnYourDataEncodedApiKeyAuthenticationOptions(OnYourDataAuthenticationType type, IDictionary serializedAdditionalRawData, string encodedApiKey) : base(type, serializedAdditionalRawData) + { + EncodedApiKey = encodedApiKey; + } + + /// Initializes a new instance of for deserialization. + internal OnYourDataEncodedApiKeyAuthenticationOptions() + { + } + + /// The encoded API key to use for authentication. + public string EncodedApiKey { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEndpointVectorizationSource.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEndpointVectorizationSource.cs index 77c4d8e550710..43b88d2f16900 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEndpointVectorizationSource.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OnYourDataEndpointVectorizationSource.cs @@ -52,7 +52,7 @@ internal OnYourDataEndpointVectorizationSource() /// /// Specifies the authentication options to use when retrieving embeddings from the specified endpoint. /// 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 available derived classes include , , , , , and . /// public OnYourDataAuthenticationOptions Authentication { get; } } diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionConfiguration.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionConfiguration.cs index 5c00d8dc13db1..0400c10e59f37 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionConfiguration.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionConfiguration.cs @@ -12,7 +12,7 @@ namespace Azure.AI.OpenAI { /// - /// A specific representation of configurable options for Elasticsearch when using it as an Azure OpenAI chat + /// A specific representation of configurable options for Pinecone when using it as an Azure OpenAI chat /// extension. /// public partial class PineconeChatExtensionConfiguration : AzureChatExtensionConfiguration diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionParameters.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionParameters.Serialization.cs index 85ed64e9b5e58..5b1eaf6d61b3b 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionParameters.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionParameters.Serialization.cs @@ -58,11 +58,8 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo writer.WriteStringValue(IndexName); writer.WritePropertyName("fieldsMapping"u8); writer.WriteObjectValue(FieldMappingOptions); - if (Optional.IsDefined(EmbeddingDependency)) - { - writer.WritePropertyName("embeddingDependency"u8); - writer.WriteObjectValue(EmbeddingDependency); - } + writer.WritePropertyName("embeddingDependency"u8); + writer.WriteObjectValue(EmbeddingDependency); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -109,7 +106,7 @@ internal static PineconeChatExtensionParameters DeserializePineconeChatExtension string environment = default; string indexName = default; PineconeFieldMappingOptions fieldsMapping = default; - Optional embeddingDependency = default; + OnYourDataVectorizationSource embeddingDependency = default; IDictionary serializedAdditionalRawData = default; Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -172,10 +169,6 @@ internal static PineconeChatExtensionParameters DeserializePineconeChatExtension } if (property.NameEquals("embeddingDependency"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } embeddingDependency = OnYourDataVectorizationSource.DeserializeOnYourDataVectorizationSource(property.Value); continue; } @@ -185,7 +178,7 @@ internal static PineconeChatExtensionParameters DeserializePineconeChatExtension } } serializedAdditionalRawData = additionalPropertiesDictionary; - return new PineconeChatExtensionParameters(authentication.Value, Optional.ToNullable(topNDocuments), Optional.ToNullable(inScope), Optional.ToNullable(strictness), roleInformation.Value, environment, indexName, fieldsMapping, embeddingDependency.Value, serializedAdditionalRawData); + return new PineconeChatExtensionParameters(authentication.Value, Optional.ToNullable(topNDocuments), Optional.ToNullable(inScope), Optional.ToNullable(strictness), roleInformation.Value, environment, indexName, fieldsMapping, embeddingDependency, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionParameters.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionParameters.cs index b2712298d12e8..4bbaf221f11a9 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionParameters.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatExtensionParameters.cs @@ -11,7 +11,7 @@ namespace Azure.AI.OpenAI { - /// Parameters for configuring Azure OpenAI Pinecone chat extensions. + /// Parameters for configuring Azure OpenAI Pinecone chat extensions. The supported authentication type is APIKey. internal partial class PineconeChatExtensionParameters { /// @@ -46,6 +46,25 @@ internal partial class PineconeChatExtensionParameters /// private IDictionary _serializedAdditionalRawData; + /// Initializes a new instance of . + /// The environment name of Pinecone. + /// The name of the Pinecone database index. + /// Customized field mapping behavior to use when interacting with the search index. + /// The embedding dependency for vector search. + /// , , or is null. + public PineconeChatExtensionParameters(string environmentName, string indexName, PineconeFieldMappingOptions fieldMappingOptions, OnYourDataVectorizationSource embeddingDependency) + { + Argument.AssertNotNull(environmentName, nameof(environmentName)); + Argument.AssertNotNull(indexName, nameof(indexName)); + Argument.AssertNotNull(fieldMappingOptions, nameof(fieldMappingOptions)); + Argument.AssertNotNull(embeddingDependency, nameof(embeddingDependency)); + + EnvironmentName = environmentName; + IndexName = indexName; + FieldMappingOptions = fieldMappingOptions; + EmbeddingDependency = embeddingDependency; + } + /// Initializes a new instance of . /// /// The authentication method to use when accessing the defined data source. @@ -84,7 +103,7 @@ internal PineconeChatExtensionParameters(OnYourDataAuthenticationOptions authent /// If not otherwise provided, On Your Data will attempt to use System Managed Identity (default credential) /// authentication. /// 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 available derived classes include , , , , , and . /// public OnYourDataAuthenticationOptions Authentication { get; set; } /// The configured top number of documents to feature for the configured query. @@ -102,6 +121,6 @@ internal PineconeChatExtensionParameters(OnYourDataAuthenticationOptions authent /// 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 OnYourDataVectorizationSource EmbeddingDependency { get; set; } + public OnYourDataVectorizationSource EmbeddingDependency { get; } } } diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeFieldMappingOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeFieldMappingOptions.Serialization.cs index 880f2ff277f53..5fd2a0c0e5dd5 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeFieldMappingOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeFieldMappingOptions.Serialization.cs @@ -42,41 +42,18 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR writer.WritePropertyName("filepathField"u8); writer.WriteStringValue(FilepathFieldName); } - if (Optional.IsCollectionDefined(ContentFieldNames)) + writer.WritePropertyName("contentFields"u8); + writer.WriteStartArray(); + foreach (var item in ContentFieldNames) { - writer.WritePropertyName("contentFields"u8); - writer.WriteStartArray(); - foreach (var item in ContentFieldNames) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } + writer.WriteEndArray(); if (Optional.IsDefined(ContentFieldSeparator)) { writer.WritePropertyName("contentFieldsSeparator"u8); writer.WriteStringValue(ContentFieldSeparator); } - if (Optional.IsCollectionDefined(VectorFieldNames)) - { - writer.WritePropertyName("vectorFields"u8); - writer.WriteStartArray(); - foreach (var item in VectorFieldNames) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (Optional.IsCollectionDefined(ImageVectorFieldNames)) - { - writer.WritePropertyName("imageVectorFields"u8); - writer.WriteStartArray(); - foreach (var item in ImageVectorFieldNames) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -118,10 +95,8 @@ internal static PineconeFieldMappingOptions DeserializePineconeFieldMappingOptio Optional titleField = default; Optional urlField = default; Optional filepathField = default; - Optional> contentFields = default; + IList contentFields = default; Optional contentFieldsSeparator = default; - Optional> vectorFields = default; - Optional> imageVectorFields = default; IDictionary serializedAdditionalRawData = default; Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -143,10 +118,6 @@ internal static PineconeFieldMappingOptions DeserializePineconeFieldMappingOptio } if (property.NameEquals("contentFields"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -160,41 +131,13 @@ internal static PineconeFieldMappingOptions DeserializePineconeFieldMappingOptio contentFieldsSeparator = property.Value.GetString(); continue; } - if (property.NameEquals("vectorFields"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - vectorFields = array; - continue; - } - if (property.NameEquals("imageVectorFields"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - imageVectorFields = array; - continue; - } if (options.Format != "W") { additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = additionalPropertiesDictionary; - return new PineconeFieldMappingOptions(titleField.Value, urlField.Value, filepathField.Value, Optional.ToList(contentFields), contentFieldsSeparator.Value, Optional.ToList(vectorFields), Optional.ToList(imageVectorFields), serializedAdditionalRawData); + return new PineconeFieldMappingOptions(titleField.Value, urlField.Value, filepathField.Value, contentFields, contentFieldsSeparator.Value, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeFieldMappingOptions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeFieldMappingOptions.cs index b152182498949..c46d685cea516 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeFieldMappingOptions.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeFieldMappingOptions.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.Linq; using Azure.Core; namespace Azure.AI.OpenAI @@ -47,11 +48,13 @@ public partial class PineconeFieldMappingOptions private IDictionary _serializedAdditionalRawData; /// Initializes a new instance of . - public PineconeFieldMappingOptions() + /// The names of index fields that should be treated as content. + /// is null. + public PineconeFieldMappingOptions(IEnumerable contentFieldNames) { - ContentFieldNames = new ChangeTrackingList(); - VectorFieldNames = new ChangeTrackingList(); - ImageVectorFieldNames = new ChangeTrackingList(); + Argument.AssertNotNull(contentFieldNames, nameof(contentFieldNames)); + + ContentFieldNames = contentFieldNames.ToList(); } /// Initializes a new instance of . @@ -60,21 +63,22 @@ public PineconeFieldMappingOptions() /// The name of the index field to use as a filepath. /// The names of index fields that should be treated as content. /// The separator pattern that content fields should use. - /// The names of fields that represent vector data. - /// The names of fields that represent image vector data. /// Keeps track of any properties unknown to the library. - internal PineconeFieldMappingOptions(string titleFieldName, string urlFieldName, string filepathFieldName, IList contentFieldNames, string contentFieldSeparator, IList vectorFieldNames, IList imageVectorFieldNames, IDictionary serializedAdditionalRawData) + internal PineconeFieldMappingOptions(string titleFieldName, string urlFieldName, string filepathFieldName, IList contentFieldNames, string contentFieldSeparator, IDictionary serializedAdditionalRawData) { TitleFieldName = titleFieldName; UrlFieldName = urlFieldName; FilepathFieldName = filepathFieldName; ContentFieldNames = contentFieldNames; ContentFieldSeparator = contentFieldSeparator; - VectorFieldNames = vectorFieldNames; - ImageVectorFieldNames = imageVectorFieldNames; _serializedAdditionalRawData = serializedAdditionalRawData; } + /// Initializes a new instance of for deserialization. + internal PineconeFieldMappingOptions() + { + } + /// The name of the index field to use as a title. public string TitleFieldName { get; set; } /// The name of the index field to use as a URL. @@ -85,9 +89,5 @@ internal PineconeFieldMappingOptions(string titleFieldName, string urlFieldName, public IList ContentFieldNames { get; } /// The separator pattern that content fields should use. public string ContentFieldSeparator { get; set; } - /// The names of fields that represent vector data. - public IList VectorFieldNames { get; } - /// The names of fields that represent image vector data. - public IList ImageVectorFieldNames { get; } } } diff --git a/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml b/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml index c9b92ca8da803..a27e94c9052c2 100644 --- a/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml +++ b/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml @@ -1,3 +1,5 @@ -directory: specification/cognitiveservices/OpenAI.Inference -commit: 848070b3dab1b5e76eee3587e99dddad8f36d6d7 repo: Azure/azure-rest-api-specs +directory: specification/cognitiveservices/OpenAI.Inference +commit: a718913e51a489e2ed6fa6a5966e5291b8018435 +additionalDirectories: [] + diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/Azure.AI.OpenAI.Assistants.sln b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/Azure.AI.OpenAI.Assistants.sln new file mode 100644 index 0000000000000..ac3546e02fe60 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/Azure.AI.OpenAI.Assistants.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.OpenAI.Assistants", "src\Azure.AI.OpenAI.Assistants.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.OpenAI.Assistants.Tests", "tests\Azure.AI.OpenAI.Assistants.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/openai/assistants/Azure.AI.OpenAI.Assistants/CHANGELOG.md b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/CHANGELOG.md new file mode 100644 index 0000000000000..13dd08af78abe --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/Directory.Build.props b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/Directory.Build.props new file mode 100644 index 0000000000000..63bd836ad44b7 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/README.md b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/README.md new file mode 100644 index 0000000000000..d31e78602f801 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/README.md @@ -0,0 +1,86 @@ +# Azure.AI.OpenAI.Assistants client library for .NET + +Azure.AI.OpenAI.Assistants 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/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants --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. + +## 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/assistants/Azure.AI.OpenAI.Assistants/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/assistants/Azure.AI.OpenAI.Assistants/README.png) diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Azure.AI.OpenAI.Assistants.csproj b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Azure.AI.OpenAI.Assistants.csproj new file mode 100644 index 0000000000000..e5c9166a89d37 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Azure.AI.OpenAI.Assistants.csproj @@ -0,0 +1,21 @@ + + + This is the Azure.AI.OpenAI.Assistants client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.AI.OpenAI.Assistants for Azure Data Plane + 1.0.0-beta.1 + Azure.AI.OpenAI.Assistants + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + + diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AIOpenAIAssistantsClientBuilderExtensions.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AIOpenAIAssistantsClientBuilderExtensions.cs new file mode 100644 index 0000000000000..23b1ed7ab371d --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AIOpenAIAssistantsClientBuilderExtensions.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.OpenAI.Assistants; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AIOpenAIAssistantsClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// An OpenAI endpoint supporting assistants functionality. + /// A credential used to authenticate to an Azure Service. + public static IAzureClientBuilder AddAssistantsClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new AssistantsClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// An OpenAI endpoint supporting assistants functionality. + public static IAzureClientBuilder AddAssistantsClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new AssistantsClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddAssistantsClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AIOpenAIAssistantsModelFactory.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AIOpenAIAssistantsModelFactory.cs new file mode 100644 index 0000000000000..3af1ff6b6196e --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AIOpenAIAssistantsModelFactory.cs @@ -0,0 +1,317 @@ +// 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.OpenAI.Assistants +{ + /// Model factory for models. + public static partial class AIOpenAIAssistantsModelFactory + { + /// Initializes a new instance of . + /// The ID of the model to use. + /// The name of the new assistant. + /// The description of the new assistant. + /// The system instructions for the new assistant to use. + /// The collection of tools to enable for the new assistant. + /// A list of previously uploaded file IDs to attach to the assistant. + /// 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 AssistantCreationOptions AssistantCreationOptions(string model = null, string name = null, string description = null, string instructions = null, IEnumerable tools = null, IEnumerable fileIds = null, IDictionary metadata = null) + { + tools ??= new List(); + fileIds ??= new List(); + metadata ??= new Dictionary(); + + return new AssistantCreationOptions(model, name, description, instructions, tools?.ToList(), fileIds?.ToList(), metadata, 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 assistant. + /// The description of the assistant. + /// The ID of the model to use. + /// The system instructions for the assistant to use. + /// The collection of tools enabled for the assistant. + /// A list of attached file IDs, ordered by creation date in ascending order. + /// 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 Assistant Assistant(string id = null, AssistantObject @object = default, DateTimeOffset createdAt = default, string name = null, string description = null, string model = null, string instructions = null, IEnumerable tools = null, IEnumerable fileIds = null, IReadOnlyDictionary metadata = null) + { + tools ??= new List(); + fileIds ??= new List(); + metadata ??= new Dictionary(); + + return new Assistant(id, @object, createdAt, name, description, model, instructions, tools?.ToList(), fileIds?.ToList(), metadata, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'assistant.file'. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The assistant ID that the file is attached to. + /// A new instance for mocking. + public static AssistantFile AssistantFile(string id = null, AssistantFileObject @object = default, DateTimeOffset createdAt = default, string assistantId = null) + { + return new AssistantFile(id, @object, createdAt, assistantId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The role associated with the assistant thread message. Currently, only 'user' is supported when providing initial messages to a new thread. + /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via a separate call to the create message API. + /// + /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can + /// access files. + /// + /// 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 ThreadInitializationMessage ThreadInitializationMessage(MessageRole role = default, string content = null, IEnumerable fileIds = null, IDictionary metadata = null) + { + fileIds ??= new List(); + metadata ??= new Dictionary(); + + return new ThreadInitializationMessage(role, content, fileIds?.ToList(), metadata, 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 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 AssistantThread AssistantThread(string id = null, AssistantThreadObject @object = default, DateTimeOffset createdAt = default, IReadOnlyDictionary metadata = null) + { + metadata ??= new Dictionary(); + + return new AssistantThread(id, @object, createdAt, 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 role associated with the assistant thread message. + /// The list of content items associated with the assistant thread message. + /// If applicable, the ID of the assistant that authored this message. + /// If applicable, the ID of the run associated with the authoring of this message. + /// + /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can + /// access files. + /// + /// 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, MessageRole role = default, IEnumerable contentItems = null, string assistantId = null, string runId = null, IEnumerable fileIds = null, IReadOnlyDictionary metadata = null) + { + contentItems ??= new List(); + fileIds ??= new List(); + metadata ??= new Dictionary(); + + return new ThreadMessage(id, @object, createdAt, threadId, role, contentItems?.ToList(), assistantId, runId, fileIds?.ToList(), 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.file'. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The ID of the message that this file is attached to. + /// A new instance for mocking. + public static MessageFile MessageFile(string id = null, MessageFileObject @object = default, DateTimeOffset createdAt = default, string messageId = null) + { + return new MessageFile(id, @object, createdAt, messageId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The ID of the assistant that should run the thread. + /// The overridden model name that the assistant should use to run the thread. + /// The overridden system instructions that the assistant 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. + /// + /// The overridden list of enabled tools that the assistant should use to run the thread. + /// 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 CreateRunOptions CreateRunOptions(string assistantId = null, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable overrideTools = null, IDictionary metadata = null) + { + overrideTools ??= new List(); + metadata ??= new Dictionary(); + + return new CreateRunOptions(assistantId, overrideModelName, overrideInstructions, additionalInstructions, overrideTools?.ToList(), metadata, 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 assistant associated with the thread this run was performed against. + /// The status of the assistant thread run. + /// The details of the action required for the assistant thread run to continue. + /// The last error, if any, encountered by this assistant thread run. + /// The ID of the model to use. + /// The overridden system instructions used for this assistant thread run. + /// The overridden enabled tools used for this assistant thread run. + /// A list of attached file IDs, ordered by creation date in ascending order. + /// 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. + /// 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 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, IEnumerable fileIds = null, DateTimeOffset createdAt = default, DateTimeOffset? expiresAt = null, DateTimeOffset? startedAt = null, DateTimeOffset? completedAt = null, DateTimeOffset? cancelledAt = null, DateTimeOffset? failedAt = null, IReadOnlyDictionary metadata = null) + { + tools ??= new List(); + fileIds ??= new List(); + metadata ??= new Dictionary(); + + return new ThreadRun(id, @object, threadId, assistantId, status, requiredAction, lastError, model, instructions, tools?.ToList(), fileIds?.ToList(), createdAt, expiresAt, startedAt, completedAt, cancelledAt, failedAt, metadata, 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 ID of the assistant for which the thread should be created. + /// The details used to create the new thread. + /// The overridden model that the assistant should use to run the thread. + /// The overridden system instructions the assistant should use to run the thread. + /// The overridden list of enabled tools the assistant should use to run the thread. + /// 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 CreateAndRunThreadOptions CreateAndRunThreadOptions(string assistantId = null, AssistantThreadCreationOptions thread = null, string overrideModelName = null, string overrideInstructions = null, IEnumerable overrideTools = null, IDictionary metadata = null) + { + overrideTools ??= new List(); + metadata ??= new Dictionary(); + + return new CreateAndRunThreadOptions(assistantId, thread, overrideModelName, overrideInstructions, overrideTools?.ToList(), metadata, 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 assistant 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. + /// 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. + /// 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, IReadOnlyDictionary metadata = null) + { + metadata ??= new Dictionary(); + + return new RunStep(id, @object, type, assistantId, threadId, runId, status, stepDetails, lastError, createdAt, expiredAt, completedAt, cancelledAt, failedAt, metadata, serializedAdditionalRawData: null); + } + + /// 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 . + /// 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. + /// 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) + { + return new OpenAIFile(@object, id, size, filename, createdAt, purpose, 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 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. + /// The key/value pairs produced by the retrieval tool. + /// A new instance for mocking. + public static RunStepRetrievalToolCall RunStepRetrievalToolCall(string id = null, IReadOnlyDictionary retrieval = null) + { + retrieval ??= new Dictionary(); + + return new RunStepRetrievalToolCall("retrieval", id, serializedAdditionalRawData: null, retrieval); + } + + /// Initializes a new instance of . + /// The object type. + /// The textual content associated with this text annotation item. + /// 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 MessageTextAnnotation MessageTextAnnotation(string type = null, string text = null, int startIndex = default, int endIndex = default) + { + return new UnknownMessageTextAnnotation(type, text, startIndex, endIndex, 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. + /// A new instance for mocking. + public static RunStepToolCallDetails RunStepToolCallDetails(IEnumerable toolCalls = null) + { + toolCalls ??= new List(); + + return new RunStepToolCallDetails(RunStepType.ToolCalls, serializedAdditionalRawData: null, toolCalls?.ToList()); + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs new file mode 100644 index 0000000000000..cdb565ebb0d41 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs @@ -0,0 +1,287 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class Assistant : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Assistant)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("createdAt"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); + } + writer.WriteEndArray(); + writer.WritePropertyName("fileIds"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Assistant 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(Assistant)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistant(document.RootElement, options); + } + + internal static Assistant DeserializeAssistant(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + AssistantObject @object = default; + DateTimeOffset createdAt = default; + string name = default; + string description = default; + string model = default; + string instructions = default; + IReadOnlyList tools = default; + IReadOnlyList fileIds = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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 AssistantObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdAt"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)); + } + tools = array; + continue; + } + if (property.NameEquals("fileIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new Assistant(id, @object, createdAt, name, description, model, instructions, tools, fileIds, 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(Assistant)} does not support '{options.Format}' format."); + } + } + + Assistant IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistant(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Assistant)} does not support '{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 Assistant FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistant(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs new file mode 100644 index 0000000000000..76d706d6aa269 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents an assistant that can call the model and use tools. + public partial class Assistant + { + /// + /// 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 assistant. + /// The description of the assistant. + /// The ID of the model to use. + /// The system instructions for the assistant to use. + /// The collection of tools enabled for the assistant. + /// A list of attached file IDs, ordered by creation date in ascending order. + /// 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 Assistant(string id, DateTimeOffset createdAt, string name, string description, string model, string instructions, IEnumerable tools, IEnumerable fileIds, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(model, nameof(model)); + Argument.AssertNotNull(tools, nameof(tools)); + Argument.AssertNotNull(fileIds, nameof(fileIds)); + + Id = id; + CreatedAt = createdAt; + Name = name; + Description = description; + Model = model; + Instructions = instructions; + Tools = tools.ToList(); + FileIds = fileIds.ToList(); + 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 assistant. + /// The description of the assistant. + /// The ID of the model to use. + /// The system instructions for the assistant to use. + /// The collection of tools enabled for the assistant. + /// A list of attached file IDs, ordered by creation date in ascending order. + /// 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 Assistant(string id, AssistantObject @object, DateTimeOffset createdAt, string name, string description, string model, string instructions, IReadOnlyList tools, IReadOnlyList fileIds, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + Name = name; + Description = description; + Model = model; + Instructions = instructions; + Tools = tools; + FileIds = fileIds; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Assistant() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always assistant. + public AssistantObject Object { get; } = AssistantObject.Assistant; + + /// The Unix timestamp, in seconds, representing when this object was created. + public DateTimeOffset CreatedAt { get; } + /// The name of the assistant. + public string Name { get; } + /// The description of the assistant. + public string Description { get; } + /// The ID of the model to use. + public string Model { get; } + /// The system instructions for the assistant to use. + public string Instructions { get; } + /// + /// The collection of tools enabled for the assistant. + /// 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 list of attached file IDs, ordered by creation date in ascending order. + public IReadOnlyList FileIds { 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs new file mode 100644 index 0000000000000..eaf7a11f3df16 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs @@ -0,0 +1,288 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class AssistantCreationOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssistantCreationOptions)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("fileIds"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AssistantCreationOptions 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(AssistantCreationOptions)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantCreationOptions(document.RootElement, options); + } + + internal static AssistantCreationOptions DeserializeAssistantCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string model = default; + Optional name = default; + Optional description = default; + Optional instructions = default; + Optional> tools = default; + Optional> fileIds = default; + Optional> metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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)); + } + tools = array; + continue; + } + if (property.NameEquals("fileIds"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("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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new AssistantCreationOptions(model, name.Value, description.Value, instructions.Value, Optional.ToList(tools), Optional.ToList(fileIds), Optional.ToDictionary(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(AssistantCreationOptions)} does not support '{options.Format}' format."); + } + } + + AssistantCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantCreationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantCreationOptions)} does not support '{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 AssistantCreationOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantCreationOptions(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs new file mode 100644 index 0000000000000..431717276aee2 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The request details to use when creating a new assistant. + public partial class AssistantCreationOptions + { + /// + /// 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. + public AssistantCreationOptions(string model) + { + Argument.AssertNotNull(model, nameof(model)); + + Model = model; + Tools = new ChangeTrackingList(); + FileIds = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The ID of the model to use. + /// The name of the new assistant. + /// The description of the new assistant. + /// The system instructions for the new assistant to use. + /// The collection of tools to enable for the new assistant. + /// A list of previously uploaded file IDs to attach to the assistant. + /// 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 AssistantCreationOptions(string model, string name, string description, string instructions, IList tools, IList fileIds, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Model = model; + Name = name; + Description = description; + Instructions = instructions; + Tools = tools; + FileIds = fileIds; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AssistantCreationOptions() + { + } + + /// The ID of the model to use. + public string Model { get; } + /// The name of the new assistant. + public string Name { get; set; } + /// The description of the new assistant. + public string Description { get; set; } + /// The system instructions for the new assistant to use. + public string Instructions { get; set; } + /// + /// The collection of tools to enable for the new assistant. + /// 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 IList Tools { get; } + /// A list of previously uploaded file IDs to attach to the assistant. + public IList FileIds { 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 IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.Serialization.cs new file mode 100644 index 0000000000000..05312645eaa93 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class AssistantFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssistantFile)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("createdAt"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("assistantId"u8); + writer.WriteStringValue(AssistantId); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AssistantFile 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(AssistantFile)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantFile(document.RootElement, options); + } + + internal static AssistantFile DeserializeAssistantFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + AssistantFileObject @object = default; + DateTimeOffset createdAt = default; + string assistantId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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 AssistantFileObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("assistantId"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new AssistantFile(id, @object, createdAt, assistantId, 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(AssistantFile)} does not support '{options.Format}' format."); + } + } + + AssistantFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantFile)} does not support '{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 AssistantFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantFile(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.cs new file mode 100644 index 0000000000000..d3d4ae1318a9f --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.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 Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Information about a file attached to an assistant, as used by tools that can read files. + public partial class AssistantFile + { + /// + /// 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 assistant ID that the file is attached to. + /// or is null. + internal AssistantFile(string id, DateTimeOffset createdAt, string assistantId) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(assistantId, nameof(assistantId)); + + Id = id; + CreatedAt = createdAt; + AssistantId = assistantId; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'assistant.file'. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The assistant ID that the file is attached to. + /// Keeps track of any properties unknown to the library. + internal AssistantFile(string id, AssistantFileObject @object, DateTimeOffset createdAt, string assistantId, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + AssistantId = assistantId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AssistantFile() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always 'assistant.file'. + public AssistantFileObject Object { get; } = AssistantFileObject.AssistantFile; + + /// The Unix timestamp, in seconds, representing when this object was created. + public DateTimeOffset CreatedAt { get; } + /// The assistant ID that the file is attached to. + public string AssistantId { get; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFileObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFileObject.cs new file mode 100644 index 0000000000000..d9bbdaaaedbaf --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFileObject.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.OpenAI.Assistants +{ + /// The AssistantFile_object. + public readonly partial struct AssistantFileObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssistantFileObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AssistantFileValue = "assistant.file"; + + /// assistant.file. + public static AssistantFileObject AssistantFile { get; } = new AssistantFileObject(AssistantFileValue); + /// Determines if two values are the same. + public static bool operator ==(AssistantFileObject left, AssistantFileObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssistantFileObject left, AssistantFileObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AssistantFileObject(string value) => new AssistantFileObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssistantFileObject other && Equals(other); + /// + public bool Equals(AssistantFileObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantObject.cs new file mode 100644 index 0000000000000..0baba5629e487 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantObject.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.OpenAI.Assistants +{ + /// The Assistant_object. + public readonly partial struct AssistantObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssistantObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AssistantValue = "assistant"; + + /// assistant. + public static AssistantObject Assistant { get; } = new AssistantObject(AssistantValue); + /// Determines if two values are the same. + public static bool operator ==(AssistantObject left, AssistantObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssistantObject left, AssistantObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AssistantObject(string value) => new AssistantObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssistantObject other && Equals(other); + /// + public bool Equals(AssistantObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs new file mode 100644 index 0000000000000..1ae82dece88c7 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class AssistantThread : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssistantThread)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("createdAt"u8); + writer.WriteNumberValue(CreatedAt, "U"); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AssistantThread 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(AssistantThread)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantThread(document.RootElement, options); + } + + internal static AssistantThread DeserializeAssistantThread(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + AssistantThreadObject @object = default; + DateTimeOffset createdAt = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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 AssistantThreadObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + createdAt = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new AssistantThread(id, @object, createdAt, 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(AssistantThread)} does not support '{options.Format}' format."); + } + } + + AssistantThread IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantThread(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantThread)} does not support '{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 AssistantThread FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantThread(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs new file mode 100644 index 0000000000000..17239e82f34a5 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Information about a single thread associated with an assistant. + public partial class AssistantThread + { + /// + /// 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 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 AssistantThread(string id, DateTimeOffset createdAt, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + CreatedAt = createdAt; + 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 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 AssistantThread(string id, AssistantThreadObject @object, DateTimeOffset createdAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AssistantThread() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always 'thread'. + public AssistantThreadObject Object { get; } = AssistantThreadObject.Thread; + + /// The Unix timestamp, in seconds, representing when this object was created. + public DateTimeOffset CreatedAt { 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs new file mode 100644 index 0000000000000..930ddd8e61fa4 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs @@ -0,0 +1,186 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class AssistantThreadCreationOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssistantThreadCreationOptions)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Messages)) + { + writer.WritePropertyName("messages"u8); + writer.WriteStartArray(); + foreach (var item in Messages) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AssistantThreadCreationOptions 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(AssistantThreadCreationOptions)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantThreadCreationOptions(document.RootElement, options); + } + + internal static AssistantThreadCreationOptions DeserializeAssistantThreadCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> messages = default; + Optional> metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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(ThreadInitializationMessage.DeserializeThreadInitializationMessage(item)); + } + messages = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new AssistantThreadCreationOptions(Optional.ToList(messages), Optional.ToDictionary(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(AssistantThreadCreationOptions)} does not support '{options.Format}' format."); + } + } + + AssistantThreadCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantThreadCreationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantThreadCreationOptions)} does not support '{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 AssistantThreadCreationOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantThreadCreationOptions(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs new file mode 100644 index 0000000000000..cb33ccd883eae --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The details used to create a new assistant thread. + public partial class AssistantThreadCreationOptions + { + /// + /// 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 AssistantThreadCreationOptions() + { + Messages = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The initial messages to associate with the new thread. + /// 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 AssistantThreadCreationOptions(IList messages, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Messages = messages; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The initial messages to associate with the new thread. + public IList Messages { 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 IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadObject.cs new file mode 100644 index 0000000000000..de51338222605 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadObject.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.OpenAI.Assistants +{ + /// The AssistantThread_object. + public readonly partial struct AssistantThreadObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssistantThreadObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadValue = "thread"; + + /// thread. + public static AssistantThreadObject Thread { get; } = new AssistantThreadObject(ThreadValue); + /// Determines if two values are the same. + public static bool operator ==(AssistantThreadObject left, AssistantThreadObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssistantThreadObject left, AssistantThreadObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AssistantThreadObject(string value) => new AssistantThreadObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssistantThreadObject other && Equals(other); + /// + public bool Equals(AssistantThreadObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs new file mode 100644 index 0000000000000..afa69037b9196 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs @@ -0,0 +1,4193 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.OpenAI.Assistants +{ + // Data plane generated client. + /// Azure OpenAI APIs for Assistants. + public partial class AssistantsClient + { + private const string AuthorizationHeader = "api-key"; + private readonly AzureKeyCredential _keyCredential; + private static readonly string[] AuthorizationScopes = new string[] { "https://cognitiveservices.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// 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 AssistantsClient for mocking. + protected AssistantsClient() + { + } + + /// Initializes a new instance of AssistantsClient. + /// An OpenAI endpoint supporting assistants functionality. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public AssistantsClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AssistantsClientOptions()) + { + } + + /// Initializes a new instance of AssistantsClient. + /// An OpenAI endpoint supporting assistants functionality. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public AssistantsClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AssistantsClientOptions()) + { + } + + /// Initializes a new instance of AssistantsClient. + /// An OpenAI endpoint supporting assistants functionality. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AssistantsClient(Uri endpoint, AzureKeyCredential credential, AssistantsClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AssistantsClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + /// Initializes a new instance of AssistantsClient. + /// An OpenAI endpoint supporting assistants functionality. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AssistantsClient(Uri endpoint, TokenCredential credential, AssistantsClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AssistantsClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + /// Creates a new assistant. + /// The request details to use when creating a new assistant. + /// The cancellation token to use. + /// is null. + public virtual async Task> CreateAssistantAsync(AssistantCreationOptions assistantCreationOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(assistantCreationOptions, nameof(assistantCreationOptions)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = assistantCreationOptions.ToRequestContent(); + Response response = await CreateAssistantAsync(content, context).ConfigureAwait(false); + return Response.FromValue(Assistant.FromResponse(response), response); + } + + /// Creates a new assistant. + /// The request details to use when creating a new assistant. + /// The cancellation token to use. + /// is null. + public virtual Response CreateAssistant(AssistantCreationOptions assistantCreationOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(assistantCreationOptions, nameof(assistantCreationOptions)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = assistantCreationOptions.ToRequestContent(); + Response response = CreateAssistant(content, context); + return Response.FromValue(Assistant.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new assistant. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request 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. + internal virtual async Task CreateAssistantAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateAssistant"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateAssistantRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new assistant. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request 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. + internal virtual Response CreateAssistant(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateAssistant"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateAssistantRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of assistants 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> InternalGetAssistantsAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalGetAssistantsAsync(limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfAssistant.FromResponse(response), response); + } + + /// Gets a list of assistants 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 InternalGetAssistants(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalGetAssistants(limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfAssistant.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of assistants 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 InternalGetAssistantsAsync(int? limit, string order, string after, string before, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetAssistants"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetAssistantsRequest(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 assistants 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 InternalGetAssistants(int? limit, string order, string after, string before, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetAssistants"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetAssistantsRequest(limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves an existing assistant. + /// The ID of the assistant to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAssistantAsync(string assistantId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAssistantAsync(assistantId, context).ConfigureAwait(false); + return Response.FromValue(Assistant.FromResponse(response), response); + } + + /// Retrieves an existing assistant. + /// The ID of the assistant to retrieve. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetAssistant(string assistantId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAssistant(assistantId, context); + return Response.FromValue(Assistant.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves an existing assistant. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the assistant 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. + internal virtual async Task GetAssistantAsync(string assistantId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetAssistant"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAssistantRequest(assistantId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves an existing assistant. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the assistant 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. + internal virtual Response GetAssistant(string assistantId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetAssistant"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAssistantRequest(assistantId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Modifies an existing assistant. + /// The ID of the assistant to modify. + /// The request details to use when modifying an existing assistant. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> UpdateAssistantAsync(string assistantId, UpdateAssistantOptions updateAssistantOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNull(updateAssistantOptions, nameof(updateAssistantOptions)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = updateAssistantOptions.ToRequestContent(); + Response response = await UpdateAssistantAsync(assistantId, content, context).ConfigureAwait(false); + return Response.FromValue(Assistant.FromResponse(response), response); + } + + /// Modifies an existing assistant. + /// The ID of the assistant to modify. + /// The request details to use when modifying an existing assistant. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response UpdateAssistant(string assistantId, UpdateAssistantOptions updateAssistantOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNull(updateAssistantOptions, nameof(updateAssistantOptions)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = updateAssistantOptions.ToRequestContent(); + Response response = UpdateAssistant(assistantId, content, context); + return Response.FromValue(Assistant.FromResponse(response), response); + } + + /// + /// [Protocol Method] Modifies an existing assistant. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the assistant 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. + internal virtual async Task UpdateAssistantAsync(string assistantId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateAssistant"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateAssistantRequest(assistantId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Modifies an existing assistant. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the assistant 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. + internal virtual Response UpdateAssistant(string assistantId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateAssistant"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateAssistantRequest(assistantId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes an assistant. + /// The ID of the assistant to delete. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalDeleteAssistantAsync(string assistantId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalDeleteAssistantAsync(assistantId, context).ConfigureAwait(false); + return Response.FromValue(InternalAssistantDeletionStatus.FromResponse(response), response); + } + + /// Deletes an assistant. + /// The ID of the assistant to delete. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response InternalDeleteAssistant(string assistantId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalDeleteAssistant(assistantId, context); + return Response.FromValue(InternalAssistantDeletionStatus.FromResponse(response), response); + } + + /// + /// [Protocol Method] Deletes an assistant. + /// + /// + /// + /// 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 assistant 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 InternalDeleteAssistantAsync(string assistantId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteAssistant"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalDeleteAssistantRequest(assistantId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Deletes an assistant. + /// + /// + /// + /// 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 assistant 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 InternalDeleteAssistant(string assistantId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteAssistant"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalDeleteAssistantRequest(assistantId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Attaches a previously uploaded file to an assistant for use by tools that can read files. + /// The ID of the assistant to attach the file to. + /// The ID of the previously uploaded file to attach. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> LinkAssistantFileAsync(string assistantId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNull(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + CreateAssistantFileRequest createAssistantFileRequest = new CreateAssistantFileRequest(fileId); + Response response = await LinkAssistantFileAsync(assistantId, createAssistantFileRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(AssistantFile.FromResponse(response), response); + } + + /// Attaches a previously uploaded file to an assistant for use by tools that can read files. + /// The ID of the assistant to attach the file to. + /// The ID of the previously uploaded file to attach. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response LinkAssistantFile(string assistantId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNull(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + CreateAssistantFileRequest createAssistantFileRequest = new CreateAssistantFileRequest(fileId); + Response response = LinkAssistantFile(assistantId, createAssistantFileRequest.ToRequestContent(), context); + return Response.FromValue(AssistantFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Attaches a previously uploaded file to an assistant for use by tools that can read files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the assistant to attach the file to. + /// 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. + internal virtual async Task LinkAssistantFileAsync(string assistantId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.LinkAssistantFile"); + scope.Start(); + try + { + using HttpMessage message = CreateLinkAssistantFileRequest(assistantId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Attaches a previously uploaded file to an assistant for use by tools that can read files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the assistant to attach the file to. + /// 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. + internal virtual Response LinkAssistantFile(string assistantId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.LinkAssistantFile"); + scope.Start(); + try + { + using HttpMessage message = CreateLinkAssistantFileRequest(assistantId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of files attached to a specific assistant, as used by tools that can read files. + /// The ID of the assistant to retrieve the list of attached files for. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalGetAssistantFilesAsync(string assistantId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalGetAssistantFilesAsync(assistantId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfAssistantFile.FromResponse(response), response); + } + + /// Gets a list of files attached to a specific assistant, as used by tools that can read files. + /// The ID of the assistant to retrieve the list of attached files for. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response InternalGetAssistantFiles(string assistantId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalGetAssistantFiles(assistantId, limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfAssistantFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of files attached to a specific assistant, as used by tools that can read 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 ID of the assistant to retrieve the list of attached files for. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. 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 InternalGetAssistantFilesAsync(string assistantId, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetAssistantFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetAssistantFilesRequest(assistantId, 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 files attached to a specific assistant, as used by tools that can read 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 ID of the assistant to retrieve the list of attached files for. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. 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 InternalGetAssistantFiles(string assistantId, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetAssistantFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetAssistantFilesRequest(assistantId, limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Retrieves a file attached to an assistant. + /// The ID of the assistant associated with the attached file. + /// The ID of the file to retrieve. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetAssistantFileAsync(string assistantId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAssistantFileAsync(assistantId, fileId, context).ConfigureAwait(false); + return Response.FromValue(AssistantFile.FromResponse(response), response); + } + + /// Retrieves a file attached to an assistant. + /// The ID of the assistant associated with the attached file. + /// The ID of the file to retrieve. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetAssistantFile(string assistantId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAssistantFile(assistantId, fileId, context); + return Response.FromValue(AssistantFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Retrieves a file attached to an assistant. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the assistant associated with the attached file. + /// The ID of the file to retrieve. + /// 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 GetAssistantFileAsync(string assistantId, string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetAssistantFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAssistantFileRequest(assistantId, fileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Retrieves a file attached to an assistant. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the assistant associated with the attached file. + /// The ID of the file to retrieve. + /// 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 GetAssistantFile(string assistantId, string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetAssistantFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAssistantFileRequest(assistantId, fileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read + /// files. + /// + /// The ID of the assistant from which the specified file should be unlinked. + /// The ID of the file to unlink from the specified assistant. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalUnlinkAssistantFileAsync(string assistantId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalUnlinkAssistantFileAsync(assistantId, fileId, context).ConfigureAwait(false); + return Response.FromValue(InternalAssistantFileDeletionStatus.FromResponse(response), response); + } + + /// + /// Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read + /// files. + /// + /// The ID of the assistant from which the specified file should be unlinked. + /// The ID of the file to unlink from the specified assistant. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + internal virtual Response InternalUnlinkAssistantFile(string assistantId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalUnlinkAssistantFile(assistantId, fileId, context); + return Response.FromValue(InternalAssistantFileDeletionStatus.FromResponse(response), response); + } + + /// + /// [Protocol Method] Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read + /// 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 ID of the assistant from which the specified file should be unlinked. + /// The ID of the file to unlink from the specified assistant. + /// 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 InternalUnlinkAssistantFileAsync(string assistantId, string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalUnlinkAssistantFile"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalUnlinkAssistantFileRequest(assistantId, fileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read + /// 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 ID of the assistant from which the specified file should be unlinked. + /// The ID of the file to unlink from the specified assistant. + /// 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 InternalUnlinkAssistantFile(string assistantId, string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalUnlinkAssistantFile"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalUnlinkAssistantFileRequest(assistantId, fileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates a new thread. Threads contain messages and can be run by assistants. + /// The details used to create a new assistant thread. + /// The cancellation token to use. + /// is null. + public virtual async Task> CreateThreadAsync(AssistantThreadCreationOptions assistantThreadCreationOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(assistantThreadCreationOptions, nameof(assistantThreadCreationOptions)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = assistantThreadCreationOptions.ToRequestContent(); + Response response = await CreateThreadAsync(content, context).ConfigureAwait(false); + return Response.FromValue(AssistantThread.FromResponse(response), response); + } + + /// Creates a new thread. Threads contain messages and can be run by assistants. + /// The details used to create a new assistant thread. + /// The cancellation token to use. + /// is null. + public virtual Response CreateThread(AssistantThreadCreationOptions assistantThreadCreationOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(assistantThreadCreationOptions, nameof(assistantThreadCreationOptions)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = assistantThreadCreationOptions.ToRequestContent(); + Response response = CreateThread(content, context); + return Response.FromValue(AssistantThread.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by assistants. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request 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. + internal virtual async Task CreateThreadAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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 assistants. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request 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. + internal virtual Response CreateThread(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThread"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateThreadRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets information about an existing thread. + /// The ID of the thread to retrieve information about. + /// 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(AssistantThread.FromResponse(response), response); + } + + /// Gets information about an existing thread. + /// The ID of the thread to retrieve information about. + /// 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(AssistantThread.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. + /// + /// + /// + /// + /// The ID of the thread to retrieve information about. + /// 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 GetThreadAsync(string threadId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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. + /// + /// + /// + /// + /// The ID of the thread to retrieve information about. + /// 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 GetThread(string threadId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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 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, IDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + RequestContext context = FromCancellationToken(cancellationToken); + UpdateThreadRequest updateThreadRequest = new UpdateThreadRequest() + { + Metadata = metadata + }; + Response response = await UpdateThreadAsync(threadId, updateThreadRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(AssistantThread.FromResponse(response), response); + } + + /// Modifies an existing thread. + /// The ID of the thread to modify. + /// 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, IDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + RequestContext context = FromCancellationToken(cancellationToken); + UpdateThreadRequest updateThreadRequest = new UpdateThreadRequest() + { + Metadata = metadata + }; + Response response = UpdateThread(threadId, updateThreadRequest.ToRequestContent(), context); + return Response.FromValue(AssistantThread.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. + /// + /// + /// + /// + /// 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. + internal 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("AssistantsClient.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. + /// + /// + /// + /// + /// 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. + internal 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("AssistantsClient.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. + /// The ID of the thread to delete. + /// 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. + /// The ID of the thread to delete. + /// 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. + /// + /// + /// + /// + /// The ID of the thread 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 InternalDeleteThreadAsync(string threadId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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. + /// + /// + /// + /// + /// The ID of the thread 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 InternalDeleteThread(string threadId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteThread"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates a new message on a specified thread. + /// The ID of the thread to create the new message on. + /// The role to associate with the new message. + /// The textual content for the new message. + /// A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files. + /// 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, string content, IEnumerable fileIds = null, IDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + RequestContext context = FromCancellationToken(cancellationToken); + CreateMessageRequest createMessageRequest = new CreateMessageRequest(role, content) + { + Metadata = metadata + }; + if (fileIds != null) + { + foreach (var value in fileIds) + { + createMessageRequest.FileIds.Add(value); + } + } + CreateMessageRequest createMessageRequest0 = createMessageRequest; + Response response = await CreateMessageAsync(threadId, createMessageRequest0.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ThreadMessage.FromResponse(response), response); + } + + /// Creates a new message on a specified thread. + /// The ID of the thread to create the new message on. + /// The role to associate with the new message. + /// The textual content for the new message. + /// A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files. + /// 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, string content, IEnumerable fileIds = null, IDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + RequestContext context = FromCancellationToken(cancellationToken); + CreateMessageRequest createMessageRequest = new CreateMessageRequest(role, content) + { + Metadata = metadata + }; + if (fileIds != null) + { + foreach (var value in fileIds) + { + createMessageRequest.FileIds.Add(value); + } + } + CreateMessageRequest createMessageRequest0 = createMessageRequest; + Response response = CreateMessage(threadId, createMessageRequest0.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. + /// + /// + /// + /// + /// The ID of the thread to create the new message on. + /// 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. + internal 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("AssistantsClient.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. + /// + /// + /// + /// + /// The ID of the thread to create the new message on. + /// 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. + internal 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("AssistantsClient.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. + /// The ID of the thread to list messages from. + /// 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, 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, 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. + /// The ID of the thread to list messages from. + /// 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, 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, 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. + /// + /// + /// + /// + /// The ID of the thread to list messages from. + /// 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, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessages"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetMessagesRequest(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 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. + /// + /// + /// + /// + /// The ID of the thread to list messages from. + /// 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, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessages"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetMessagesRequest(threadId, limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets an existing message from an existing thread. + /// The ID of the thread to retrieve the specified message from. + /// The ID of the message to retrieve from the specified thread. + /// 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); + } + + /// Gets an existing message from an existing thread. + /// The ID of the thread to retrieve the specified message from. + /// The ID of the message to retrieve from the specified thread. + /// 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] Gets an existing message from an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread to retrieve the specified message from. + /// The ID of the message to retrieve from the specified thread. + /// 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 GetMessageAsync(string threadId, string messageId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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] Gets an existing message from an existing thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread to retrieve the specified message from. + /// The ID of the message to retrieve from the specified thread. + /// 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 GetMessage(string threadId, string messageId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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. + /// The ID of the thread containing the specified message to modify. + /// The ID of the message to modify on the specified thread. + /// 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, IDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + RequestContext context = FromCancellationToken(cancellationToken); + UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest() + { + Metadata = metadata + }; + 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. + /// The ID of the thread containing the specified message to modify. + /// The ID of the message to modify on the specified thread. + /// 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, IDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + RequestContext context = FromCancellationToken(cancellationToken); + UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest() + { + Metadata = metadata + }; + 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. + /// + /// + /// + /// + /// The ID of the thread containing the specified message to modify. + /// The ID of the message to modify on the specified 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. + /// 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 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("AssistantsClient.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. + /// + /// + /// + /// + /// The ID of the thread containing the specified message to modify. + /// The ID of the message to modify on the specified 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. + /// 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 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("AssistantsClient.UpdateMessage"); + scope.Start(); + try + { + using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of previously uploaded files associated with a message from a thread. + /// The ID of the thread containing the message to list files from. + /// The ID of the message to list files from. + /// 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> InternalGetMessageFilesAsync(string threadId, string messageId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalGetMessageFilesAsync(threadId, messageId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfMessageFile.FromResponse(response), response); + } + + /// Gets a list of previously uploaded files associated with a message from a thread. + /// The ID of the thread containing the message to list files from. + /// The ID of the message to list files from. + /// 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 InternalGetMessageFiles(string threadId, string messageId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalGetMessageFiles(threadId, messageId, limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfMessageFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of previously uploaded files associated with a message from 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. + /// + /// + /// + /// + /// The ID of the thread containing the message to list files from. + /// The ID of the message to list files from. + /// 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 InternalGetMessageFilesAsync(string threadId, string messageId, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessageFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetMessageFilesRequest(threadId, messageId, 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 previously uploaded files associated with a message from 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. + /// + /// + /// + /// + /// The ID of the thread containing the message to list files from. + /// The ID of the message to list files from. + /// 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 InternalGetMessageFiles(string threadId, string messageId, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessageFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetMessageFilesRequest(threadId, messageId, limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets information about a file attachment to a message within a thread. + /// The ID of the thread containing the message to get information from. + /// The ID of the message to get information from. + /// The ID of the file to get information about. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public virtual async Task> GetMessageFileAsync(string threadId, string messageId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetMessageFileAsync(threadId, messageId, fileId, context).ConfigureAwait(false); + return Response.FromValue(MessageFile.FromResponse(response), response); + } + + /// Gets information about a file attachment to a message within a thread. + /// The ID of the thread containing the message to get information from. + /// The ID of the message to get information from. + /// The ID of the file to get information about. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public virtual Response GetMessageFile(string threadId, string messageId, string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetMessageFile(threadId, messageId, fileId, context); + return Response.FromValue(MessageFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets information about a file attachment to a message within a thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread containing the message to get information from. + /// The ID of the message to get information from. + /// The ID of the file to get information about. + /// 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 GetMessageFileAsync(string threadId, string messageId, string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessageFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMessageFileRequest(threadId, messageId, fileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets information about a file attachment to a message within a thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread containing the message to get information from. + /// The ID of the message to get information from. + /// The ID of the file to get information about. + /// 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 GetMessageFile(string threadId, string messageId, string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessageFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMessageFileRequest(threadId, messageId, fileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates a new run for an assistant thread. + /// The ID of the thread to run. + /// The details for the run to create. + /// 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, CreateRunOptions createRunOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(createRunOptions, nameof(createRunOptions)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = createRunOptions.ToRequestContent(); + Response response = await CreateRunAsync(threadId, content, context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Creates a new run for an assistant thread. + /// The ID of the thread to run. + /// The details for the run to create. + /// 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, CreateRunOptions createRunOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(createRunOptions, nameof(createRunOptions)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = createRunOptions.ToRequestContent(); + Response response = CreateRun(threadId, content, context); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new run for an assistant thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread to 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. + /// 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 CreateRunAsync(string threadId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRunRequest(threadId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new run for an assistant thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread to 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. + /// 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 CreateRun(string threadId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRunRequest(threadId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of runs for a specified thread. + /// The ID of the thread to list runs from. + /// 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. + /// The ID of the thread to list runs from. + /// 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. + /// + /// + /// + /// + /// The ID of the thread to list runs from. + /// 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("AssistantsClient.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. + /// + /// + /// + /// + /// The ID of the thread to list runs from. + /// 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("AssistantsClient.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. + /// The ID of the thread to retrieve run information from. + /// The ID of the thread to retrieve information about. + /// 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. + /// The ID of the thread to retrieve run information from. + /// The ID of the thread to retrieve information about. + /// 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. + /// + /// + /// + /// + /// The ID of the thread to retrieve run information from. + /// The ID of the thread to retrieve information about. + /// 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 GetRunAsync(string threadId, string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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. + /// + /// + /// + /// + /// The ID of the thread to retrieve run information from. + /// The ID of the thread to retrieve information about. + /// 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 GetRun(string threadId, string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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. + /// The ID of the thread associated with the specified run. + /// The ID of the run to modify. + /// 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, IDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + UpdateRunRequest updateRunRequest = new UpdateRunRequest() + { + Metadata = metadata + }; + Response response = await UpdateRunAsync(threadId, runId, updateRunRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Modifies an existing thread run. + /// The ID of the thread associated with the specified run. + /// The ID of the run to modify. + /// 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, IDictionary metadata = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + UpdateRunRequest updateRunRequest = new UpdateRunRequest() + { + Metadata = metadata + }; + 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. + /// + /// + /// + /// + /// The ID of the thread associated with the specified run. + /// The ID of the run 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. + /// 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 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("AssistantsClient.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. + /// + /// + /// + /// + /// The ID of the thread associated with the specified run. + /// The ID of the run 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. + /// 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 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("AssistantsClient.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. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. + /// The ID of the thread that was run. + /// The ID of the run that requires tool outputs. + /// The list of tool outputs requested by tool calls from the specified 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> SubmitToolOutputsToRunAsync(string threadId, string runId, IEnumerable toolOutputs, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + + RequestContext context = FromCancellationToken(cancellationToken); + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList()); + 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. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. + /// The ID of the thread that was run. + /// The ID of the run that requires tool outputs. + /// The list of tool outputs requested by tool calls from the specified run. + /// 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, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + + RequestContext context = FromCancellationToken(cancellationToken); + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList()); + 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. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the run that requires tool outputs. + /// 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. + internal 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("AssistantsClient.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. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the run that requires tool outputs. + /// 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. + internal 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("AssistantsClient.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. + /// The ID of the thread being run. + /// The ID of the run to cancel. + /// 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. + /// The ID of the thread being run. + /// The ID of the run to cancel. + /// 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. + /// + /// + /// + /// + /// The ID of the thread being run. + /// The ID of the run to cancel. + /// 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 CancelRunAsync(string threadId, string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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. + /// + /// + /// + /// + /// The ID of the thread being run. + /// The ID of the run to cancel. + /// 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 CancelRun(string threadId, string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CancelRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelRunRequest(threadId, runId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates a new assistant thread and immediately starts a run using that new thread. + /// The details used when creating and immediately running a new assistant thread. + /// The cancellation token to use. + /// is null. + public virtual async Task> CreateThreadAndRunAsync(CreateAndRunThreadOptions createAndRunThreadOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(createAndRunThreadOptions, nameof(createAndRunThreadOptions)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = createAndRunThreadOptions.ToRequestContent(); + Response response = await CreateThreadAndRunAsync(content, context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Creates a new assistant thread and immediately starts a run using that new thread. + /// The details used when creating and immediately running a new assistant thread. + /// The cancellation token to use. + /// is null. + public virtual Response CreateThreadAndRun(CreateAndRunThreadOptions createAndRunThreadOptions, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(createAndRunThreadOptions, nameof(createAndRunThreadOptions)); + + RequestContext context = FromCancellationToken(cancellationToken); + using RequestContent content = createAndRunThreadOptions.ToRequestContent(); + Response response = CreateThreadAndRun(content, context); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new assistant 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. + /// + /// + /// + /// + /// 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. + internal virtual async Task CreateThreadAndRunAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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 assistant 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. + /// + /// + /// + /// + /// 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. + internal virtual Response CreateThreadAndRun(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThreadAndRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateThreadAndRunRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a single run step from a thread run. + /// The ID of the thread that was run. + /// The ID of the specific run to retrieve the step from. + /// The ID of the step to retrieve information about. + /// 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, 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, context).ConfigureAwait(false); + return Response.FromValue(RunStep.FromResponse(response), response); + } + + /// Gets a single run step from a thread run. + /// The ID of the thread that was run. + /// The ID of the specific run to retrieve the step from. + /// The ID of the step to retrieve information about. + /// 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, 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, context); + return Response.FromValue(RunStep.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets 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. + /// + /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the specific run to retrieve the step from. + /// The ID of the step to retrieve information about. + /// 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 GetRunStepAsync(string threadId, string runId, string stepId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRunStep"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets 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. + /// + /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the specific run to retrieve the step from. + /// The ID of the step to retrieve information about. + /// 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 GetRunStep(string threadId, string runId, string stepId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRunStep"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of run steps from a thread run. + /// The ID of the thread that was run. + /// The ID of the run to list steps from. + /// 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, 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, 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. + /// The ID of the thread that was run. + /// The ID of the run to list steps from. + /// 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, 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, 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. + /// + /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the run to list steps from. + /// 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, 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("AssistantsClient.InternalGetRunSteps"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetRunStepsRequest(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 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. + /// + /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the run to list steps from. + /// 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, 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("AssistantsClient.InternalGetRunSteps"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of previously uploaded files. + /// A value that, when provided, limits list results to files matching the corresponding purpose. + /// 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. + /// A value that, when provided, limits list results to files matching the corresponding purpose. + /// 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. + /// + /// + /// + /// + /// A value that, when provided, limits list results to files matching the corresponding purpose. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output". + /// 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("AssistantsClient.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. + /// + /// + /// + /// + /// A value that, when provided, limits list results to files matching the corresponding purpose. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output". + /// 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("AssistantsClient.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. + /// The file data (not filename) to upload. + /// The intended purpose of the file. + /// A filename to associate with the uploaded data. + /// The cancellation token to use. + /// is null. + public virtual async Task> UploadFileAsync(BinaryData data, OpenAIFilePurpose purpose, string filename = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + RequestContext context = FromCancellationToken(cancellationToken); + UploadFileRequest uploadFileRequest = new UploadFileRequest(data, purpose) + { + Filename = filename + }; + Response response = await UploadFileAsync(uploadFileRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(OpenAIFile.FromResponse(response), response); + } + + /// Uploads a file for use by other operations. + /// The file data (not filename) to upload. + /// The intended purpose of the file. + /// A filename to associate with the uploaded data. + /// The cancellation token to use. + /// is null. + public virtual Response UploadFile(BinaryData data, OpenAIFilePurpose purpose, string filename = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + RequestContext context = FromCancellationToken(cancellationToken); + UploadFileRequest uploadFileRequest = new UploadFileRequest(data, purpose) + { + Filename = filename + }; + Response response = UploadFile(uploadFileRequest.ToRequestContent(), 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. + /// + /// + /// + /// + /// 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. + internal virtual async Task UploadFileAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UploadFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadFileRequest(content, 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. + /// + /// + /// + /// + /// 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. + internal virtual Response UploadFile(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UploadFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadFileRequest(content, 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("AssistantsClient.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("AssistantsClient.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. + /// + /// + /// + /// + /// 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. + internal virtual async Task GetFileAsync(string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.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. + /// + /// + /// + /// + /// 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. + internal virtual Response GetFile(string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetFileRequest(fileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCreateAssistantRequest(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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalGetAssistantsRequest(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); + 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 CreateGetAssistantRequest(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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUpdateAssistantRequest(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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalDeleteAssistantRequest(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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateLinkAssistantFileRequest(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.AppendPath("/files", false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalGetAssistantFilesRequest(string assistantId, 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.AppendPath(assistantId, true); + uri.AppendPath("/files", false); + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetAssistantFileRequest(string assistantId, 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("/assistants/", false); + uri.AppendPath(assistantId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateInternalUnlinkAssistantFileRequest(string assistantId, 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("/assistants/", false); + uri.AppendPath(assistantId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + 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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + 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); + 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); + 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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + 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); + 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, 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); + 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); + 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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateInternalGetMessageFilesRequest(string threadId, string messageId, 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.AppendPath(messageId, true); + uri.AppendPath("/files", false); + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMessageFileRequest(string threadId, string messageId, 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("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages/", false); + uri.AppendPath(messageId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateRunRequest(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("/runs", false); + 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); + 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); + 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); + 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); + 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); + 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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetRunStepRequest(string threadId, string runId, string stepId, 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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateInternalGetRunStepsRequest(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("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/steps", false); + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + 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); + if (purpose != null) + { + uri.AppendQuery("purpose", purpose, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUploadFileRequest(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("/files", false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-type", "multipart/form-data"); + 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); + 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); + 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClientOptions.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClientOptions.cs new file mode 100644 index 0000000000000..a847db2052bd4 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClientOptions.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.OpenAI.Assistants +{ + /// Client options for AssistantsClient. + public partial class AssistantsClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_02_15_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2024-02-15-preview". + V2024_02_15_Preview = 1, + } + + internal string Version { get; } + + /// Initializes new instance of AssistantsClientOptions. + public AssistantsClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2024_02_15_Preview => "2024-02-15-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolDefinition.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolDefinition.Serialization.cs new file mode 100644 index 0000000000000..c3d274302d263 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolDefinition.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class CodeInterpreterToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCodeInterpreterToolDefinition(document.RootElement, options); + } + + internal static CodeInterpreterToolDefinition DeserializeCodeInterpreterToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeCodeInterpreterToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support '{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); + return DeserializeCodeInterpreterToolDefinition(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolDefinition.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolDefinition.cs new file mode 100644 index 0000000000000..a057579590fca --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// The input definition information for a code interpreter tool as used to configure an assistant. + 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.Serialization.cs new file mode 100644 index 0000000000000..610c16b6782da --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.Serialization.cs @@ -0,0 +1,231 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class CreateAndRunThreadOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateAndRunThreadOptions)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("assistantId"u8); + writer.WriteStringValue(AssistantId); + if (Optional.IsDefined(Thread)) + { + writer.WritePropertyName("thread"u8); + writer.WriteObjectValue(Thread); + } + if (Optional.IsDefined(OverrideModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(OverrideModelName); + } + if (Optional.IsDefined(OverrideInstructions)) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(OverrideInstructions); + } + if (Optional.IsCollectionDefined(OverrideTools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in OverrideTools) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CreateAndRunThreadOptions 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(CreateAndRunThreadOptions)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateAndRunThreadOptions(document.RootElement, options); + } + + internal static CreateAndRunThreadOptions DeserializeCreateAndRunThreadOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string assistantId = default; + Optional thread = default; + Optional model = default; + Optional instructions = default; + Optional> tools = default; + Optional> metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("assistantId"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("thread"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + thread = AssistantThreadCreationOptions.DeserializeAssistantThreadCreationOptions(property.Value); + 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)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ToolDefinition.DeserializeToolDefinition(item)); + } + tools = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new CreateAndRunThreadOptions(assistantId, thread.Value, model.Value, instructions.Value, Optional.ToList(tools), Optional.ToDictionary(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(CreateAndRunThreadOptions)} does not support '{options.Format}' format."); + } + } + + CreateAndRunThreadOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCreateAndRunThreadOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateAndRunThreadOptions)} does not support '{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 CreateAndRunThreadOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCreateAndRunThreadOptions(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.cs new file mode 100644 index 0000000000000..cbdc0d7202a37 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The details used when creating and immediately running a new assistant thread. + public partial class CreateAndRunThreadOptions + { + /// + /// 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 assistant for which the thread should be created. + /// is null. + public CreateAndRunThreadOptions(string assistantId) + { + Argument.AssertNotNull(assistantId, nameof(assistantId)); + + AssistantId = assistantId; + OverrideTools = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The ID of the assistant for which the thread should be created. + /// The details used to create the new thread. + /// The overridden model that the assistant should use to run the thread. + /// The overridden system instructions the assistant should use to run the thread. + /// The overridden list of enabled tools the assistant should use to run the thread. + /// 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 CreateAndRunThreadOptions(string assistantId, AssistantThreadCreationOptions thread, string overrideModelName, string overrideInstructions, IList overrideTools, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + AssistantId = assistantId; + Thread = thread; + OverrideModelName = overrideModelName; + OverrideInstructions = overrideInstructions; + OverrideTools = overrideTools; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateAndRunThreadOptions() + { + } + + /// The ID of the assistant for which the thread should be created. + public string AssistantId { get; } + /// The details used to create the new thread. + public AssistantThreadCreationOptions Thread { get; set; } + /// The overridden model that the assistant should use to run the thread. + public string OverrideModelName { get; set; } + /// The overridden system instructions the assistant should use to run the thread. + public string OverrideInstructions { get; set; } + /// + /// The overridden list of enabled tools the assistant 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 IList OverrideTools { 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 IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.Serialization.cs new file mode 100644 index 0000000000000..89f1a07ff09fe --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class CreateAssistantFileRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateAssistantFileRequest)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("fileId"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CreateAssistantFileRequest 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(CreateAssistantFileRequest)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateAssistantFileRequest(document.RootElement, options); + } + + internal static CreateAssistantFileRequest DeserializeCreateAssistantFileRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileId"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new CreateAssistantFileRequest(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(CreateAssistantFileRequest)} does not support '{options.Format}' format."); + } + } + + CreateAssistantFileRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCreateAssistantFileRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateAssistantFileRequest)} does not support '{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 CreateAssistantFileRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCreateAssistantFileRequest(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.cs new file mode 100644 index 0000000000000..f60662741a54c --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The CreateAssistantFileRequest. + internal partial class CreateAssistantFileRequest + { + /// + /// 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 file to attach. + /// is null. + public CreateAssistantFileRequest(string fileId) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + } + + /// Initializes a new instance of . + /// The ID of the previously uploaded file to attach. + /// Keeps track of any properties unknown to the library. + internal CreateAssistantFileRequest(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateAssistantFileRequest() + { + } + + /// The ID of the previously uploaded file to attach. + public string FileId { get; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.Serialization.cs new file mode 100644 index 0000000000000..d08ff07bc16d2 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.Serialization.cs @@ -0,0 +1,202 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class CreateMessageRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("fileIds"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateMessageRequest(document.RootElement, options); + } + + internal static CreateMessageRequest DeserializeCreateMessageRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageRole role = default; + string content = default; + Optional> fileIds = default; + Optional> metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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 = property.Value.GetString(); + continue; + } + if (property.NameEquals("fileIds"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("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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new CreateMessageRequest(role, content, Optional.ToList(fileIds), Optional.ToDictionary(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(CreateMessageRequest)} does not support '{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); + return DeserializeCreateMessageRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support '{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); + return DeserializeCreateMessageRequest(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.cs new file mode 100644 index 0000000000000..63771aac904e7 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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 to associate with the new message. + /// The textual content for the new message. + /// is null. + public CreateMessageRequest(MessageRole role, string content) + { + Argument.AssertNotNull(content, nameof(content)); + + Role = role; + Content = content; + FileIds = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The role to associate with the new message. + /// The textual content for the new message. + /// A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files. + /// 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, string content, IList fileIds, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Role = role; + Content = content; + FileIds = fileIds; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateMessageRequest() + { + } + + /// The role to associate with the new message. + public MessageRole Role { get; } + /// The textual content for the new message. + public string Content { get; } + /// A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files. + public IList FileIds { 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 IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.Serialization.cs new file mode 100644 index 0000000000000..f70abd3ccd68c --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.Serialization.cs @@ -0,0 +1,270 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class CreateRunOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateRunOptions)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("assistantId"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("additionalInstructions"u8); + writer.WriteStringValue(AdditionalInstructions); + } + else + { + writer.WriteNull("additionalInstructions"); + } + } + if (Optional.IsCollectionDefined(OverrideTools)) + { + if (OverrideTools != null) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in OverrideTools) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("tools"); + } + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CreateRunOptions 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(CreateRunOptions)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateRunOptions(document.RootElement, options); + } + + internal static CreateRunOptions DeserializeCreateRunOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string assistantId = default; + Optional model = default; + Optional instructions = default; + Optional additionalInstructions = default; + Optional> tools = default; + Optional> metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("assistantId"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("additionalInstructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + additionalInstructions = null; + continue; + } + additionalInstructions = 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)); + } + tools = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new CreateRunOptions(assistantId, model.Value, instructions.Value, additionalInstructions.Value, Optional.ToList(tools), Optional.ToDictionary(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(CreateRunOptions)} does not support '{options.Format}' format."); + } + } + + CreateRunOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCreateRunOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateRunOptions)} does not support '{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 CreateRunOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCreateRunOptions(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.cs new file mode 100644 index 0000000000000..b1cc3ee18151f --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The details used when creating a new run of an assistant thread. + public partial class CreateRunOptions + { + /// + /// 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 assistant that should run the thread. + /// is null. + public CreateRunOptions(string assistantId) + { + Argument.AssertNotNull(assistantId, nameof(assistantId)); + + AssistantId = assistantId; + OverrideTools = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The ID of the assistant that should run the thread. + /// The overridden model name that the assistant should use to run the thread. + /// The overridden system instructions that the assistant 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. + /// + /// The overridden list of enabled tools that the assistant should use to run the thread. + /// 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 CreateRunOptions(string assistantId, string overrideModelName, string overrideInstructions, string additionalInstructions, IList overrideTools, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + AssistantId = assistantId; + OverrideModelName = overrideModelName; + OverrideInstructions = overrideInstructions; + AdditionalInstructions = additionalInstructions; + OverrideTools = overrideTools; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateRunOptions() + { + } + + /// The ID of the assistant that should run the thread. + public string AssistantId { get; } + /// The overridden model name that the assistant should use to run the thread. + public string OverrideModelName { get; set; } + /// The overridden system instructions that the assistant should use to run the thread. + public string OverrideInstructions { get; set; } + /// + /// 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; set; } + /// + /// The overridden list of enabled tools that the assistant 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 IList OverrideTools { 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/FunctionToolDefinition.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/FunctionToolDefinition.Serialization.cs new file mode 100644 index 0000000000000..838898bbf5163 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/FunctionToolDefinition.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class FunctionToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(InternalFunction); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionToolDefinition(document.RootElement, options); + } + + internal static FunctionToolDefinition DeserializeFunctionToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalFunctionDefinition function = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("function"u8)) + { + function = InternalFunctionDefinition.DeserializeInternalFunctionDefinition(property.Value); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeFunctionToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support '{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); + return DeserializeFunctionToolDefinition(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/FunctionToolDefinition.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/FunctionToolDefinition.cs new file mode 100644 index 0000000000000..8683bda0026b0 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/FunctionToolDefinition.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The input definition information for a function tool as used to configure an assistant. + 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatus.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatus.Serialization.cs new file mode 100644 index 0000000000000..87882d1e43fdb --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatus.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalAssistantDeletionStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAssistantDeletionStatus)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalAssistantDeletionStatus 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(InternalAssistantDeletionStatus)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAssistantDeletionStatus(document.RootElement, options); + } + + internal static InternalAssistantDeletionStatus DeserializeInternalAssistantDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalAssistantDeletionStatusObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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 InternalAssistantDeletionStatusObject(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new InternalAssistantDeletionStatus(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(InternalAssistantDeletionStatus)} does not support '{options.Format}' format."); + } + } + + InternalAssistantDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAssistantDeletionStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAssistantDeletionStatus)} does not support '{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 InternalAssistantDeletionStatus FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAssistantDeletionStatus(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatus.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatus.cs new file mode 100644 index 0000000000000..044de1fc40a5e --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatus.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The status of an assistant deletion operation. + internal partial class InternalAssistantDeletionStatus + { + /// + /// 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 InternalAssistantDeletionStatus(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 InternalAssistantDeletionStatus(string id, bool deleted, InternalAssistantDeletionStatusObject @object, IDictionary serializedAdditionalRawData) + { + Id = id; + Deleted = deleted; + Object = @object; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalAssistantDeletionStatus() + { + } + + /// 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 InternalAssistantDeletionStatusObject Object { get; } = InternalAssistantDeletionStatusObject.AssistantDeleted; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatusObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatusObject.cs new file mode 100644 index 0000000000000..0a206a9567cd7 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantDeletionStatusObject.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.OpenAI.Assistants +{ + /// The InternalAssistantDeletionStatus_object. + internal readonly partial struct InternalAssistantDeletionStatusObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public InternalAssistantDeletionStatusObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AssistantDeletedValue = "assistant.deleted"; + + /// assistant.deleted. + public static InternalAssistantDeletionStatusObject AssistantDeleted { get; } = new InternalAssistantDeletionStatusObject(AssistantDeletedValue); + /// Determines if two values are the same. + public static bool operator ==(InternalAssistantDeletionStatusObject left, InternalAssistantDeletionStatusObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(InternalAssistantDeletionStatusObject left, InternalAssistantDeletionStatusObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator InternalAssistantDeletionStatusObject(string value) => new InternalAssistantDeletionStatusObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalAssistantDeletionStatusObject other && Equals(other); + /// + public bool Equals(InternalAssistantDeletionStatusObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.Serialization.cs new file mode 100644 index 0000000000000..1c62084250021 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalAssistantFileDeletionStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAssistantFileDeletionStatus)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalAssistantFileDeletionStatus 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(InternalAssistantFileDeletionStatus)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAssistantFileDeletionStatus(document.RootElement, options); + } + + internal static InternalAssistantFileDeletionStatus DeserializeInternalAssistantFileDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalAssistantFileDeletionStatusObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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 InternalAssistantFileDeletionStatusObject(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new InternalAssistantFileDeletionStatus(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(InternalAssistantFileDeletionStatus)} does not support '{options.Format}' format."); + } + } + + InternalAssistantFileDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAssistantFileDeletionStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAssistantFileDeletionStatus)} does not support '{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 InternalAssistantFileDeletionStatus FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAssistantFileDeletionStatus(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.cs new file mode 100644 index 0000000000000..beedfc174cb78 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The status of an assistant file deletion operation. + internal partial class InternalAssistantFileDeletionStatus + { + /// + /// 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 InternalAssistantFileDeletionStatus(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.file.deleted'. + /// Keeps track of any properties unknown to the library. + internal InternalAssistantFileDeletionStatus(string id, bool deleted, InternalAssistantFileDeletionStatusObject @object, IDictionary serializedAdditionalRawData) + { + Id = id; + Deleted = deleted; + Object = @object; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalAssistantFileDeletionStatus() + { + } + + /// 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.file.deleted'. + public InternalAssistantFileDeletionStatusObject Object { get; } = InternalAssistantFileDeletionStatusObject.AssistantFileDeleted; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatusObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatusObject.cs new file mode 100644 index 0000000000000..45976bbd09370 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatusObject.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.OpenAI.Assistants +{ + /// The InternalAssistantFileDeletionStatus_object. + internal readonly partial struct InternalAssistantFileDeletionStatusObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public InternalAssistantFileDeletionStatusObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AssistantFileDeletedValue = "assistant.file.deleted"; + + /// assistant.file.deleted. + public static InternalAssistantFileDeletionStatusObject AssistantFileDeleted { get; } = new InternalAssistantFileDeletionStatusObject(AssistantFileDeletedValue); + /// Determines if two values are the same. + public static bool operator ==(InternalAssistantFileDeletionStatusObject left, InternalAssistantFileDeletionStatusObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(InternalAssistantFileDeletionStatusObject left, InternalAssistantFileDeletionStatusObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator InternalAssistantFileDeletionStatusObject(string value) => new InternalAssistantFileDeletionStatusObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalAssistantFileDeletionStatusObject other && Equals(other); + /// + public bool Equals(InternalAssistantFileDeletionStatusObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs new file mode 100644 index 0000000000000..66074bc68776d --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalCodeInterpreterToolCallDetails.Serialization.cs @@ -0,0 +1,154 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalCodeInterpreterToolCallDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("input"u8); + writer.WriteStringValue(Input); + writer.WritePropertyName("outputs"u8); + writer.WriteStartArray(); + foreach (var item in Outputs) + { + writer.WriteObjectValue(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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterToolCallDetails(document.RootElement, options); + } + + internal static InternalCodeInterpreterToolCallDetails DeserializeInternalCodeInterpreterToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string input = default; + IReadOnlyList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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)); + } + outputs = array; + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeInternalCodeInterpreterToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallDetails)} does not support '{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); + return DeserializeInternalCodeInterpreterToolCallDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalCodeInterpreterToolCallDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalCodeInterpreterToolCallDetails.cs new file mode 100644 index 0000000000000..c91769ba1cfe6 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalCodeInterpreterToolCallDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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. + /// 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. + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatus.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatus.Serialization.cs new file mode 100644 index 0000000000000..1a3851d7c3d57 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatus.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalFileDeletionStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileDeletionStatus)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileDeletionStatus(document.RootElement, options); + } + + internal static InternalFileDeletionStatus DeserializeInternalFileDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalFileDeletionStatusObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeInternalFileDeletionStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileDeletionStatus)} does not support '{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); + return DeserializeInternalFileDeletionStatus(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatus.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatus.cs new file mode 100644 index 0000000000000..937617a1c5d8d --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatus.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatusObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileDeletionStatusObject.cs new file mode 100644 index 0000000000000..867dfbf1583bb --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponse.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponse.Serialization.cs new file mode 100644 index 0000000000000..61ac8b856ea6f --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponse.Serialization.cs @@ -0,0 +1,154 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalFileListResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileListResponse)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileListResponse(document.RootElement, options); + } + + internal static InternalFileListResponse DeserializeInternalFileListResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalFileListResponseObject @object = default; + IReadOnlyList data = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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)); + } + data = array; + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeInternalFileListResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileListResponse)} does not support '{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); + return DeserializeInternalFileListResponse(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponse.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponse.cs new file mode 100644 index 0000000000000..7c106251212b7 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponse.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; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponseObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFileListResponseObject.cs new file mode 100644 index 0000000000000..4690ffa145395 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFunctionDefinition.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFunctionDefinition.Serialization.cs new file mode 100644 index 0000000000000..7363c689c36e4 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFunctionDefinition.Serialization.cs @@ -0,0 +1,162 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalFunctionDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("parameters"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Parameters); +#else + using (JsonDocument document = JsonDocument.Parse(Parameters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionDefinition(document.RootElement, options); + } + + internal static InternalFunctionDefinition DeserializeInternalFunctionDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + Optional description = default; + BinaryData parameters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new InternalFunctionDefinition(name, description.Value, 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 '{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); + return DeserializeInternalFunctionDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support '{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); + return DeserializeInternalFunctionDefinition(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFunctionDefinition.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFunctionDefinition.cs new file mode 100644 index 0000000000000..5dc65ec4a2cb3 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalFunctionDefinition.cs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.Serialization.cs new file mode 100644 index 0000000000000..6b5454ddd20dc --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalMessageImageFileDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageImageFileDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("fileId"u8); + writer.WriteObjectValue(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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageImageFileDetails(document.RootElement, options); + } + + internal static InternalMessageImageFileDetails DeserializeInternalMessageImageFileDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMessageImageFileIdDetails fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileId"u8)) + { + fileId = InternalMessageImageFileIdDetails.DeserializeInternalMessageImageFileIdDetails(property.Value); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeInternalMessageImageFileDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageImageFileDetails)} does not support '{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); + return DeserializeInternalMessageImageFileDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.cs new file mode 100644 index 0000000000000..8b8f2efbcb1fa --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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(InternalMessageImageFileIdDetails 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(InternalMessageImageFileIdDetails 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 InternalMessageImageFileIdDetails InternalDetails { get; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileIdDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileIdDetails.Serialization.cs new file mode 100644 index 0000000000000..21f48fe44f68a --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileIdDetails.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalMessageImageFileIdDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageImageFileIdDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("fileId"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InternalMessageImageFileIdDetails 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(InternalMessageImageFileIdDetails)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageImageFileIdDetails(document.RootElement, options); + } + + internal static InternalMessageImageFileIdDetails DeserializeInternalMessageImageFileIdDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileId"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new InternalMessageImageFileIdDetails(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(InternalMessageImageFileIdDetails)} does not support '{options.Format}' format."); + } + } + + InternalMessageImageFileIdDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageImageFileIdDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageImageFileIdDetails)} does not support '{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 InternalMessageImageFileIdDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageImageFileIdDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileIdDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileIdDetails.cs new file mode 100644 index 0000000000000..92bc2193e9abc --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileIdDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// An encapsulation of an image file ID, as used by message image content. + internal partial class InternalMessageImageFileIdDetails + { + /// + /// 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 image file. + /// is null. + internal InternalMessageImageFileIdDetails(string fileId) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + } + + /// Initializes a new instance of . + /// The ID of the specific image file. + /// Keeps track of any properties unknown to the library. + internal InternalMessageImageFileIdDetails(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal InternalMessageImageFileIdDetails() + { + } + + /// The ID of the specific image file. + public string FileId { get; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.Serialization.cs new file mode 100644 index 0000000000000..ba917b8e3d867 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.Serialization.cs @@ -0,0 +1,154 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalMessageTextDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageTextDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Text); + writer.WritePropertyName("annotations"u8); + writer.WriteStartArray(); + foreach (var item in Annotations) + { + writer.WriteObjectValue(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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageTextDetails(document.RootElement, options); + } + + internal static InternalMessageTextDetails DeserializeInternalMessageTextDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + IReadOnlyList annotations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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)); + } + annotations = array; + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeInternalMessageTextDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageTextDetails)} does not support '{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); + return DeserializeInternalMessageTextDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.cs new file mode 100644 index 0000000000000..77f06da0bb5d4 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The text and associated annotations for a single item of assistant 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. + /// 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. + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.Serialization.cs new file mode 100644 index 0000000000000..e7f4dd0d1739c --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalMessageTextFileCitationDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageTextFileCitationDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("fileId"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageTextFileCitationDetails(document.RootElement, options); + } + + internal static InternalMessageTextFileCitationDetails DeserializeInternalMessageTextFileCitationDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string quote = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileId"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("quote"u8)) + { + quote = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeInternalMessageTextFileCitationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageTextFileCitationDetails)} does not support '{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); + return DeserializeInternalMessageTextFileCitationDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.cs new file mode 100644 index 0000000000000..b7feb88df762d --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.Serialization.cs new file mode 100644 index 0000000000000..e7f9dd915c70f --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalMessageTextFilePathDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMessageTextFilePathDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("fileId"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageTextFilePathDetails(document.RootElement, options); + } + + internal static InternalMessageTextFilePathDetails DeserializeInternalMessageTextFilePathDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileId"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeInternalMessageTextFilePathDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageTextFilePathDetails)} does not support '{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); + return DeserializeInternalMessageTextFilePathDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.cs new file mode 100644 index 0000000000000..1232dcf47366b --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRequiredFunctionToolCallDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRequiredFunctionToolCallDetails.Serialization.cs new file mode 100644 index 0000000000000..b9a0c61bbd084 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRequiredFunctionToolCallDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalRequiredFunctionToolCallDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCallDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRequiredFunctionToolCallDetails(document.RootElement, options); + } + + internal static InternalRequiredFunctionToolCallDetails DeserializeInternalRequiredFunctionToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeInternalRequiredFunctionToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCallDetails)} does not support '{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); + return DeserializeInternalRequiredFunctionToolCallDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRequiredFunctionToolCallDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRequiredFunctionToolCallDetails.cs new file mode 100644 index 0000000000000..a96389225209d --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRequiredFunctionToolCallDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRunStepFunctionToolCallDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRunStepFunctionToolCallDetails.Serialization.cs new file mode 100644 index 0000000000000..40e54548aced4 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRunStepFunctionToolCallDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalRunStepFunctionToolCallDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement, options); + } + + internal static InternalRunStepFunctionToolCallDetails DeserializeInternalRunStepFunctionToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + string output = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support '{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); + return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRunStepFunctionToolCallDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRunStepFunctionToolCallDetails.cs new file mode 100644 index 0000000000000..209482509e583 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalRunStepFunctionToolCallDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs new file mode 100644 index 0000000000000..2147d73669e69 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalSubmitToolOutputsDetails.Serialization.cs @@ -0,0 +1,146 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class InternalSubmitToolOutputsDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalSubmitToolOutputsDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("toolCalls"u8); + writer.WriteStartArray(); + foreach (var item in ToolCalls) + { + writer.WriteObjectValue(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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalSubmitToolOutputsDetails(document.RootElement, options); + } + + internal static InternalSubmitToolOutputsDetails DeserializeInternalSubmitToolOutputsDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList toolCalls = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("toolCalls"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RequiredToolCall.DeserializeRequiredToolCall(item)); + } + toolCalls = array; + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeInternalSubmitToolOutputsDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalSubmitToolOutputsDetails)} does not support '{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); + return DeserializeInternalSubmitToolOutputsDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalSubmitToolOutputsDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalSubmitToolOutputsDetails.cs new file mode 100644 index 0000000000000..82c13ede5f465 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/InternalSubmitToolOutputsDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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 assistant thread run to continue. + /// 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 assistant thread run to continue. + /// 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 assistant 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ListSortOrder.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ListSortOrder.cs new file mode 100644 index 0000000000000..0a77cab2824bf --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageContent.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageContent.Serialization.cs new file mode 100644 index 0000000000000..e50c2d8a35467 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageContent.Serialization.cs @@ -0,0 +1,128 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownMessageContent))] + public partial class MessageContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageContent)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageContent(document.RootElement, options); + } + + internal static MessageContent DeserializeMessageContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "text": return MessageTextContent.DeserializeMessageTextContent(element); + case "image_file": return MessageImageFileContent.DeserializeMessageImageFileContent(element); + } + } + return UnknownMessageContent.DeserializeUnknownMessageContent(element); + } + + 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 '{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); + return DeserializeMessageContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageContent)} does not support '{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); + return DeserializeMessageContent(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageContent.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageContent.cs new file mode 100644 index 0000000000000..86764d6ee16e8 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.Serialization.cs new file mode 100644 index 0000000000000..cfe77758e5657 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageFile)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("createdAt"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("messageId"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageFile 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(MessageFile)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageFile(document.RootElement, options); + } + + internal static MessageFile DeserializeMessageFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + MessageFileObject @object = default; + DateTimeOffset createdAt = default; + string messageId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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 MessageFileObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("messageId"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new MessageFile(id, @object, createdAt, 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(MessageFile)} does not support '{options.Format}' format."); + } + } + + MessageFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageFile)} does not support '{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 MessageFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageFile(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.cs new file mode 100644 index 0000000000000..0340a0c9ffe45 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.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 Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Information about a file attached to an assistant thread message. + public partial class MessageFile + { + /// + /// 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 message that this file is attached to. + /// or is null. + internal MessageFile(string id, DateTimeOffset createdAt, string messageId) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(messageId, nameof(messageId)); + + Id = id; + CreatedAt = createdAt; + MessageId = messageId; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always 'thread.message.file'. + /// The Unix timestamp, in seconds, representing when this object was created. + /// The ID of the message that this file is attached to. + /// Keeps track of any properties unknown to the library. + internal MessageFile(string id, MessageFileObject @object, DateTimeOffset createdAt, string messageId, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + MessageId = messageId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageFile() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always 'thread.message.file'. + public MessageFileObject Object { get; } = MessageFileObject.ThreadMessageFile; + + /// The Unix timestamp, in seconds, representing when this object was created. + public DateTimeOffset CreatedAt { get; } + /// The ID of the message that this file is attached to. + public string MessageId { get; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFileObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFileObject.cs new file mode 100644 index 0000000000000..1163bca9b9c26 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageFileObject.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.OpenAI.Assistants +{ + /// The MessageFile_object. + public readonly partial struct MessageFileObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageFileObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadMessageFileValue = "thread.message.file"; + + /// thread.message.file. + public static MessageFileObject ThreadMessageFile { get; } = new MessageFileObject(ThreadMessageFileValue); + /// Determines if two values are the same. + public static bool operator ==(MessageFileObject left, MessageFileObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageFileObject left, MessageFileObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MessageFileObject(string value) => new MessageFileObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageFileObject other && Equals(other); + /// + public bool Equals(MessageFileObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.Serialization.cs new file mode 100644 index 0000000000000..8709d38796ec9 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageImageFileContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageImageFileContent)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("imageFile"u8); + writer.WriteObjectValue(InternalDetails); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageImageFileContent(document.RootElement, options); + } + + internal static MessageImageFileContent DeserializeMessageImageFileContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMessageImageFileDetails imageFile = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("imageFile"u8)) + { + imageFile = InternalMessageImageFileDetails.DeserializeInternalMessageImageFileDetails(property.Value); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeMessageImageFileContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageImageFileContent)} does not support '{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); + return DeserializeMessageImageFileContent(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.cs new file mode 100644 index 0000000000000..f9411b334b0ac --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageRole.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageRole.cs new file mode 100644 index 0000000000000..d1c7c68c35c55 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 AssistantValue = "assistant"; + + /// The role representing the end-user. + public static MessageRole User { get; } = new MessageRole(UserValue); + /// The role representing the assistant. + public static MessageRole Assistant { get; } = new MessageRole(AssistantValue); + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.Serialization.cs new file mode 100644 index 0000000000000..96f127b5c2a68 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownMessageTextAnnotation))] + public partial class MessageTextAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + writer.WritePropertyName("startIndex"u8); + writer.WriteNumberValue(StartIndex); + writer.WritePropertyName("endIndex"u8); + writer.WriteNumberValue(EndIndex); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextAnnotation(document.RootElement, options); + } + + internal static MessageTextAnnotation DeserializeMessageTextAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "file_citation": return MessageTextFileCitationAnnotation.DeserializeMessageTextFileCitationAnnotation(element); + case "file_path": return MessageTextFilePathAnnotation.DeserializeMessageTextFilePathAnnotation(element); + } + } + return UnknownMessageTextAnnotation.DeserializeUnknownMessageTextAnnotation(element); + } + + 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 '{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); + return DeserializeMessageTextAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support '{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); + return DeserializeMessageTextAnnotation(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.cs new file mode 100644 index 0000000000000..95cec642d71d5 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// 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. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + /// is null. + protected MessageTextAnnotation(string text, int startIndex, int endIndex) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + StartIndex = startIndex; + EndIndex = endIndex; + } + + /// Initializes a new instance of . + /// The object type. + /// The textual content associated with this text annotation item. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + /// Keeps track of any properties unknown to the library. + internal MessageTextAnnotation(string type, string text, int startIndex, int endIndex, IDictionary serializedAdditionalRawData) + { + Type = type; + Text = text; + StartIndex = startIndex; + EndIndex = endIndex; + _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; } + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.Serialization.cs new file mode 100644 index 0000000000000..5b0edb96d4473 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageTextContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextContent)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("text"u8); + writer.WriteObjectValue(InternalDetails); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextContent(document.RootElement, options); + } + + internal static MessageTextContent DeserializeMessageTextContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMessageTextDetails text = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) + { + text = InternalMessageTextDetails.DeserializeInternalMessageTextDetails(property.Value); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeMessageTextContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextContent)} does not support '{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); + return DeserializeMessageTextContent(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.cs new file mode 100644 index 0000000000000..b19bcf32bc19e --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs new file mode 100644 index 0000000000000..23234141bbfde --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageTextFileCitationAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextFileCitationAnnotation)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("fileCitation"u8); + writer.WriteObjectValue(InternalDetails); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + writer.WritePropertyName("startIndex"u8); + writer.WriteNumberValue(StartIndex); + writer.WritePropertyName("endIndex"u8); + writer.WriteNumberValue(EndIndex); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextFileCitationAnnotation(document.RootElement, options); + } + + internal static MessageTextFileCitationAnnotation DeserializeMessageTextFileCitationAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMessageTextFileCitationDetails fileCitation = default; + string type = default; + string text = default; + int startIndex = default; + int endIndex = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileCitation"u8)) + { + fileCitation = InternalMessageTextFileCitationDetails.DeserializeInternalMessageTextFileCitationDetails(property.Value); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("startIndex"u8)) + { + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("endIndex"u8)) + { + endIndex = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new MessageTextFileCitationAnnotation(type, text, startIndex, endIndex, serializedAdditionalRawData, fileCitation); + } + + 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 '{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); + return DeserializeMessageTextFileCitationAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextFileCitationAnnotation)} does not support '{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); + return DeserializeMessageTextFileCitationAnnotation(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.cs new file mode 100644 index 0000000000000..e9f599bdaa6e3 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the 'retrieval' tool to search files. + public partial class MessageTextFileCitationAnnotation : MessageTextAnnotation + { + /// Initializes a new instance of . + /// The textual content associated with this text annotation item. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + /// + /// A citation within the message that points to a specific quote from a specific file. + /// Generated when the assistant uses the "retrieval" tool to search files. + /// + /// or is null. + internal MessageTextFileCitationAnnotation(string text, int startIndex, int endIndex, InternalMessageTextFileCitationDetails internalDetails) : base(text, startIndex, endIndex) + { + 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. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + /// 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 assistant uses the "retrieval" tool to search files. + /// + internal MessageTextFileCitationAnnotation(string type, string text, int startIndex, int endIndex, IDictionary serializedAdditionalRawData, InternalMessageTextFileCitationDetails internalDetails) : base(type, text, startIndex, endIndex, serializedAdditionalRawData) + { + InternalDetails = internalDetails; + } + + /// 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 assistant uses the "retrieval" tool to search files. + /// + public InternalMessageTextFileCitationDetails InternalDetails { get; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.Serialization.cs new file mode 100644 index 0000000000000..67f88f8075157 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageTextFilePathAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextFilePathAnnotation)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("filePath"u8); + writer.WriteObjectValue(InternalDetails); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + writer.WritePropertyName("startIndex"u8); + writer.WriteNumberValue(StartIndex); + writer.WritePropertyName("endIndex"u8); + writer.WriteNumberValue(EndIndex); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageTextFilePathAnnotation(document.RootElement, options); + } + + internal static MessageTextFilePathAnnotation DeserializeMessageTextFilePathAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMessageTextFilePathDetails filePath = default; + string type = default; + string text = default; + int startIndex = default; + int endIndex = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("filePath"u8)) + { + filePath = InternalMessageTextFilePathDetails.DeserializeInternalMessageTextFilePathDetails(property.Value); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("startIndex"u8)) + { + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("endIndex"u8)) + { + endIndex = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new MessageTextFilePathAnnotation(type, text, startIndex, endIndex, serializedAdditionalRawData, filePath); + } + + 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 '{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); + return DeserializeMessageTextFilePathAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextFilePathAnnotation)} does not support '{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); + return DeserializeMessageTextFilePathAnnotation(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.cs new file mode 100644 index 0000000000000..c096320efd245 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + /// A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file. + /// or is null. + internal MessageTextFilePathAnnotation(string text, int startIndex, int endIndex, InternalMessageTextFilePathDetails internalDetails) : base(text, startIndex, endIndex) + { + 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. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + /// Keeps track of any properties unknown to the library. + /// A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file. + internal MessageTextFilePathAnnotation(string type, string text, int startIndex, int endIndex, IDictionary serializedAdditionalRawData, InternalMessageTextFilePathDetails internalDetails) : base(type, text, startIndex, endIndex, serializedAdditionalRawData) + { + InternalDetails = internalDetails; + } + + /// Initializes a new instance of for deserialization. + internal MessageTextFilePathAnnotation() + { + } + + /// A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file. + public InternalMessageTextFilePathDetails InternalDetails { get; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.Serialization.cs new file mode 100644 index 0000000000000..fa73b0827e1f2 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class OpenAIFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIFile)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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("createdAt"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("purpose"u8); + writer.WriteStringValue(Purpose.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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIFile(document.RootElement, options); + } + + internal static OpenAIFile DeserializeOpenAIFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + 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; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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("createdAt"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("purpose"u8)) + { + purpose = new OpenAIFilePurpose(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new OpenAIFile(@object, id, bytes, filename, createdAt, purpose, 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 '{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); + return DeserializeOpenAIFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIFile)} does not support '{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); + return DeserializeOpenAIFile(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.cs new file mode 100644 index 0000000000000..300744d8cdf11 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents an assistant 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. + /// Keeps track of any properties unknown to the library. + internal OpenAIFile(OpenAIFileObject @object, string id, int size, string filename, DateTimeOffset createdAt, OpenAIFilePurpose purpose, IDictionary serializedAdditionalRawData) + { + Object = @object; + Id = id; + Size = size; + Filename = filename; + CreatedAt = createdAt; + Purpose = purpose; + _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; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFileObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFileObject.cs new file mode 100644 index 0000000000000..c244d438210f6 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFilePurpose.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFilePurpose.cs new file mode 100644 index 0000000000000..5622ece16fddb --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFilePurpose.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.OpenAI.Assistants +{ + /// 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 AssistantsValue = "assistants"; + private const string AssistantsOutputValue = "assistants_output"; + + /// 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 assistants. + public static OpenAIFilePurpose Assistants { get; } = new OpenAIFilePurpose(AssistantsValue); + /// Indicates a file is used as output by assistants. + public static OpenAIFilePurpose AssistantsOutput { get; } = new OpenAIFilePurpose(AssistantsOutputValue); + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistant.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistant.Serialization.cs new file mode 100644 index 0000000000000..525ee7ef59c10 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistant.Serialization.cs @@ -0,0 +1,178 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class OpenAIPageableListOfAssistant : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfAssistant)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("firstId"u8); + writer.WriteStringValue(FirstId); + writer.WritePropertyName("lastId"u8); + writer.WriteStringValue(LastId); + writer.WritePropertyName("hasMore"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OpenAIPageableListOfAssistant 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(OpenAIPageableListOfAssistant)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfAssistant(document.RootElement, options); + } + + internal static OpenAIPageableListOfAssistant DeserializeOpenAIPageableListOfAssistant(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfAssistantObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfAssistantObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Assistant.DeserializeAssistant(item)); + } + data = array; + continue; + } + if (property.NameEquals("firstId"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastId"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("hasMore"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new OpenAIPageableListOfAssistant(@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(OpenAIPageableListOfAssistant)} does not support '{options.Format}' format."); + } + } + + OpenAIPageableListOfAssistant IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOpenAIPageableListOfAssistant(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfAssistant)} does not support '{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 OpenAIPageableListOfAssistant FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOpenAIPageableListOfAssistant(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistant.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistant.cs new file mode 100644 index 0000000000000..ef5ebeab69277 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistant.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The response data for a requested list of items. + internal partial class OpenAIPageableListOfAssistant + { + /// + /// 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 OpenAIPageableListOfAssistant(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 OpenAIPageableListOfAssistant(OpenAIPageableListOfAssistantObject @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 OpenAIPageableListOfAssistant() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfAssistantObject Object { get; } = OpenAIPageableListOfAssistantObject.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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFile.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFile.Serialization.cs new file mode 100644 index 0000000000000..c198342074769 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFile.Serialization.cs @@ -0,0 +1,178 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class OpenAIPageableListOfAssistantFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfAssistantFile)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("firstId"u8); + writer.WriteStringValue(FirstId); + writer.WritePropertyName("lastId"u8); + writer.WriteStringValue(LastId); + writer.WritePropertyName("hasMore"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OpenAIPageableListOfAssistantFile 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(OpenAIPageableListOfAssistantFile)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfAssistantFile(document.RootElement, options); + } + + internal static OpenAIPageableListOfAssistantFile DeserializeOpenAIPageableListOfAssistantFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfAssistantFileObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfAssistantFileObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AssistantFile.DeserializeAssistantFile(item)); + } + data = array; + continue; + } + if (property.NameEquals("firstId"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastId"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("hasMore"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new OpenAIPageableListOfAssistantFile(@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(OpenAIPageableListOfAssistantFile)} does not support '{options.Format}' format."); + } + } + + OpenAIPageableListOfAssistantFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOpenAIPageableListOfAssistantFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfAssistantFile)} does not support '{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 OpenAIPageableListOfAssistantFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOpenAIPageableListOfAssistantFile(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFile.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFile.cs new file mode 100644 index 0000000000000..9c581ea45b0e2 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFile.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The response data for a requested list of items. + internal partial class OpenAIPageableListOfAssistantFile + { + /// + /// 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 OpenAIPageableListOfAssistantFile(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 OpenAIPageableListOfAssistantFile(OpenAIPageableListOfAssistantFileObject @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 OpenAIPageableListOfAssistantFile() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfAssistantFileObject Object { get; } = OpenAIPageableListOfAssistantFileObject.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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFileObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFileObject.cs new file mode 100644 index 0000000000000..56a4b12929c12 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFileObject.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.OpenAI.Assistants +{ + /// The OpenAIPageableListOfAssistantFile_object. + internal readonly partial struct OpenAIPageableListOfAssistantFileObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfAssistantFileObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfAssistantFileObject List { get; } = new OpenAIPageableListOfAssistantFileObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfAssistantFileObject left, OpenAIPageableListOfAssistantFileObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfAssistantFileObject left, OpenAIPageableListOfAssistantFileObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OpenAIPageableListOfAssistantFileObject(string value) => new OpenAIPageableListOfAssistantFileObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfAssistantFileObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfAssistantFileObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantObject.cs new file mode 100644 index 0000000000000..46e773c0c35b4 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantObject.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.OpenAI.Assistants +{ + /// The OpenAIPageableListOfAssistant_object. + internal readonly partial struct OpenAIPageableListOfAssistantObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfAssistantObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfAssistantObject List { get; } = new OpenAIPageableListOfAssistantObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfAssistantObject left, OpenAIPageableListOfAssistantObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfAssistantObject left, OpenAIPageableListOfAssistantObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OpenAIPageableListOfAssistantObject(string value) => new OpenAIPageableListOfAssistantObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfAssistantObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfAssistantObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFile.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFile.Serialization.cs new file mode 100644 index 0000000000000..ae51c92404714 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFile.Serialization.cs @@ -0,0 +1,178 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class OpenAIPageableListOfMessageFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfMessageFile)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("firstId"u8); + writer.WriteStringValue(FirstId); + writer.WritePropertyName("lastId"u8); + writer.WriteStringValue(LastId); + writer.WritePropertyName("hasMore"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OpenAIPageableListOfMessageFile 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(OpenAIPageableListOfMessageFile)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfMessageFile(document.RootElement, options); + } + + internal static OpenAIPageableListOfMessageFile DeserializeOpenAIPageableListOfMessageFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIPageableListOfMessageFileObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) + { + @object = new OpenAIPageableListOfMessageFileObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageFile.DeserializeMessageFile(item)); + } + data = array; + continue; + } + if (property.NameEquals("firstId"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastId"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("hasMore"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new OpenAIPageableListOfMessageFile(@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(OpenAIPageableListOfMessageFile)} does not support '{options.Format}' format."); + } + } + + OpenAIPageableListOfMessageFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOpenAIPageableListOfMessageFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfMessageFile)} does not support '{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 OpenAIPageableListOfMessageFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOpenAIPageableListOfMessageFile(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFile.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFile.cs new file mode 100644 index 0000000000000..f205ce8353ccc --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFile.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The response data for a requested list of items. + internal partial class OpenAIPageableListOfMessageFile + { + /// + /// 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 OpenAIPageableListOfMessageFile(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 OpenAIPageableListOfMessageFile(OpenAIPageableListOfMessageFileObject @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 OpenAIPageableListOfMessageFile() + { + } + + /// The object type, which is always list. + public OpenAIPageableListOfMessageFileObject Object { get; } = OpenAIPageableListOfMessageFileObject.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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFileObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFileObject.cs new file mode 100644 index 0000000000000..de78651dc7c73 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFileObject.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.OpenAI.Assistants +{ + /// The OpenAIPageableListOfMessageFile_object. + internal readonly partial struct OpenAIPageableListOfMessageFileObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfMessageFileObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfMessageFileObject List { get; } = new OpenAIPageableListOfMessageFileObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfMessageFileObject left, OpenAIPageableListOfMessageFileObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfMessageFileObject left, OpenAIPageableListOfMessageFileObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OpenAIPageableListOfMessageFileObject(string value) => new OpenAIPageableListOfMessageFileObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfMessageFileObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfMessageFileObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStep.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStep.Serialization.cs new file mode 100644 index 0000000000000..96beaf5c989c6 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStep.Serialization.cs @@ -0,0 +1,178 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class OpenAIPageableListOfRunStep : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfRunStep)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("firstId"u8); + writer.WriteStringValue(FirstId); + writer.WritePropertyName("lastId"u8); + writer.WriteStringValue(LastId); + writer.WritePropertyName("hasMore"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfRunStep(document.RootElement, options); + } + + internal static OpenAIPageableListOfRunStep DeserializeOpenAIPageableListOfRunStep(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + 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 additionalPropertiesDictionary = 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)); + } + data = array; + continue; + } + if (property.NameEquals("firstId"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastId"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("hasMore"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeOpenAIPageableListOfRunStep(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfRunStep)} does not support '{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); + return DeserializeOpenAIPageableListOfRunStep(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStep.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStep.cs new file mode 100644 index 0000000000000..b3e501616d1b7 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStep.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStepObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfRunStepObject.cs new file mode 100644 index 0000000000000..c2917cdcb9a65 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessage.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessage.Serialization.cs new file mode 100644 index 0000000000000..fcb23bedabf69 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessage.Serialization.cs @@ -0,0 +1,178 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class OpenAIPageableListOfThreadMessage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadMessage)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("firstId"u8); + writer.WriteStringValue(FirstId); + writer.WritePropertyName("lastId"u8); + writer.WriteStringValue(LastId); + writer.WritePropertyName("hasMore"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfThreadMessage(document.RootElement, options); + } + + internal static OpenAIPageableListOfThreadMessage DeserializeOpenAIPageableListOfThreadMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + 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 additionalPropertiesDictionary = 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)); + } + data = array; + continue; + } + if (property.NameEquals("firstId"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastId"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("hasMore"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeOpenAIPageableListOfThreadMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadMessage)} does not support '{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); + return DeserializeOpenAIPageableListOfThreadMessage(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessage.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessage.cs new file mode 100644 index 0000000000000..6052271533d43 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessage.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessageObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadMessageObject.cs new file mode 100644 index 0000000000000..03431876112ee --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRun.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRun.Serialization.cs new file mode 100644 index 0000000000000..0515277ab4fd8 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRun.Serialization.cs @@ -0,0 +1,178 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class OpenAIPageableListOfThreadRun : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadRun)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("firstId"u8); + writer.WriteStringValue(FirstId); + writer.WritePropertyName("lastId"u8); + writer.WriteStringValue(LastId); + writer.WritePropertyName("hasMore"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIPageableListOfThreadRun(document.RootElement, options); + } + + internal static OpenAIPageableListOfThreadRun DeserializeOpenAIPageableListOfThreadRun(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + 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 additionalPropertiesDictionary = 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)); + } + data = array; + continue; + } + if (property.NameEquals("firstId"u8)) + { + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastId"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("hasMore"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeOpenAIPageableListOfThreadRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIPageableListOfThreadRun)} does not support '{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); + return DeserializeOpenAIPageableListOfThreadRun(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRun.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRun.cs new file mode 100644 index 0000000000000..ef3d283eac680 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRun.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRunObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfThreadRunObject.cs new file mode 100644 index 0000000000000..e12f29c2b5142 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredAction.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredAction.Serialization.cs new file mode 100644 index 0000000000000..92b0930efe4f9 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredAction.Serialization.cs @@ -0,0 +1,127 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownRequiredAction))] + public partial class RequiredAction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredAction)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequiredAction(document.RootElement, options); + } + + internal static RequiredAction DeserializeRequiredAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + 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); + } + } + return UnknownRequiredAction.DeserializeUnknownRequiredAction(element); + } + + 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 '{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); + return DeserializeRequiredAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredAction)} does not support '{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); + return DeserializeRequiredAction(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredAction.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredAction.cs new file mode 100644 index 0000000000000..ceb1a3feb5182 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// + /// An abstract representation of a required action for an assistant 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredFunctionToolCall.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredFunctionToolCall.Serialization.cs new file mode 100644 index 0000000000000..25302cd84146e --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredFunctionToolCall.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RequiredFunctionToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredFunctionToolCall)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(InternalDetails); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequiredFunctionToolCall(document.RootElement, options); + } + + internal static RequiredFunctionToolCall DeserializeRequiredFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalRequiredFunctionToolCallDetails function = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("function"u8)) + { + function = InternalRequiredFunctionToolCallDetails.DeserializeInternalRequiredFunctionToolCallDetails(property.Value); + 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRequiredFunctionToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredFunctionToolCall)} does not support '{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); + return DeserializeRequiredFunctionToolCall(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredFunctionToolCall.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredFunctionToolCall.cs new file mode 100644 index 0000000000000..f989c1f772cd3 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredFunctionToolCall.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredToolCall.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredToolCall.Serialization.cs new file mode 100644 index 0000000000000..fe33876bb0e83 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredToolCall.Serialization.cs @@ -0,0 +1,129 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownRequiredToolCall))] + public partial class RequiredToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequiredToolCall(document.RootElement, options); + } + + internal static RequiredToolCall DeserializeRequiredToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "function": return RequiredFunctionToolCall.DeserializeRequiredFunctionToolCall(element); + } + } + return UnknownRequiredToolCall.DeserializeUnknownRequiredToolCall(element); + } + + 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 '{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); + return DeserializeRequiredToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support '{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); + return DeserializeRequiredToolCall(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredToolCall.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredToolCall.cs new file mode 100644 index 0000000000000..0e7b20869a0cf --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RequiredToolCall.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// An abstract representation a 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.Serialization.cs new file mode 100644 index 0000000000000..075aa95c73381 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RetrievalToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RetrievalToolDefinition)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RetrievalToolDefinition 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(RetrievalToolDefinition)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRetrievalToolDefinition(document.RootElement, options); + } + + internal static RetrievalToolDefinition DeserializeRetrievalToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new RetrievalToolDefinition(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(RetrievalToolDefinition)} does not support '{options.Format}' format."); + } + } + + RetrievalToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRetrievalToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RetrievalToolDefinition)} does not support '{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 RetrievalToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRetrievalToolDefinition(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.cs new file mode 100644 index 0000000000000..f2f39855b348d --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.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.OpenAI.Assistants +{ + /// The input definition information for a retrieval tool as used to configure an assistant. + public partial class RetrievalToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + public RetrievalToolDefinition() + { + Type = "retrieval"; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal RetrievalToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunError.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunError.Serialization.cs new file mode 100644 index 0000000000000..064367c9da83a --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunError.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunError)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunError(document.RootElement, options); + } + + internal static RunError DeserializeRunError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRunError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunError)} does not support '{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); + return DeserializeRunError(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunError.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunError.cs new file mode 100644 index 0000000000000..08cc091c19567 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunError.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The details of an error as encountered by an assistant 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStatus.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStatus.cs new file mode 100644 index 0000000000000..c673fc9bcf342 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// Possible values for the status of an assistant 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.Serialization.cs new file mode 100644 index 0000000000000..4f43d636af3d8 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.Serialization.cs @@ -0,0 +1,331 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStep : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStep)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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("assistantId"u8); + writer.WriteStringValue(AssistantId); + writer.WritePropertyName("threadId"u8); + writer.WriteStringValue(ThreadId); + writer.WritePropertyName("runId"u8); + writer.WriteStringValue(RunId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("stepDetails"u8); + writer.WriteObjectValue(StepDetails); + if (LastError != null) + { + writer.WritePropertyName("lastError"u8); + writer.WriteObjectValue(LastError); + } + else + { + writer.WriteNull("lastError"); + } + writer.WritePropertyName("createdAt"u8); + writer.WriteNumberValue(CreatedAt, "U"); + if (ExpiredAt != null) + { + writer.WritePropertyName("expiredAt"u8); + writer.WriteStringValue(ExpiredAt.Value, "O"); + } + else + { + writer.WriteNull("expiredAt"); + } + if (CompletedAt != null) + { + writer.WritePropertyName("completedAt"u8); + writer.WriteStringValue(CompletedAt.Value, "O"); + } + else + { + writer.WriteNull("completedAt"); + } + if (CancelledAt != null) + { + writer.WritePropertyName("cancelledAt"u8); + writer.WriteStringValue(CancelledAt.Value, "O"); + } + else + { + writer.WriteNull("cancelledAt"); + } + if (FailedAt != null) + { + writer.WritePropertyName("failedAt"u8); + writer.WriteStringValue(FailedAt.Value, "O"); + } + else + { + writer.WriteNull("failedAt"); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStep(document.RootElement, options); + } + + internal static RunStep DeserializeRunStep(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + 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; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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("assistantId"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("threadId"u8)) + { + threadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("runId"u8)) + { + runId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new RunStepStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("stepDetails"u8)) + { + stepDetails = RunStepDetails.DeserializeRunStepDetails(property.Value); + continue; + } + if (property.NameEquals("lastError"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastError = null; + continue; + } + lastError = RunStepError.DeserializeRunStepError(property.Value); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("expiredAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + expiredAt = null; + continue; + } + expiredAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + completedAt = null; + continue; + } + completedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("cancelledAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + cancelledAt = null; + continue; + } + cancelledAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("failedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + failedAt = null; + continue; + } + failedAt = property.Value.GetDateTimeOffset("O"); + 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new RunStep(id, @object, type, assistantId, threadId, runId, status, stepDetails, lastError, createdAt, expiredAt, completedAt, cancelledAt, failedAt, 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 '{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); + return DeserializeRunStep(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStep)} does not support '{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); + return DeserializeRunStep(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.cs new file mode 100644 index 0000000000000..fcde491f0a5ca --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.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 Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Detailed information about a single step of an assistant 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 assistant 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. + /// 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 assistant 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. + /// 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. + /// 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, 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; + 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 assistant 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; } + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageOutput.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageOutput.Serialization.cs new file mode 100644 index 0000000000000..66fc28b7597b7 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageOutput.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class RunStepCodeInterpreterImageOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageOutput)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("image"u8); + writer.WriteObjectValue(Image); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterImageOutput(document.RootElement, options); + } + + internal static RunStepCodeInterpreterImageOutput DeserializeRunStepCodeInterpreterImageOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepCodeInterpreterImageReference image = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image"u8)) + { + image = RunStepCodeInterpreterImageReference.DeserializeRunStepCodeInterpreterImageReference(property.Value); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRunStepCodeInterpreterImageOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageOutput)} does not support '{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); + return DeserializeRunStepCodeInterpreterImageOutput(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageOutput.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageOutput.cs new file mode 100644 index 0000000000000..153266c0cdc25 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageOutput.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageReference.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageReference.Serialization.cs new file mode 100644 index 0000000000000..f01e7d6044d7a --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageReference.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class RunStepCodeInterpreterImageReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageReference)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("fileId"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterImageReference(document.RootElement, options); + } + + internal static RunStepCodeInterpreterImageReference DeserializeRunStepCodeInterpreterImageReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileId"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRunStepCodeInterpreterImageReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterImageReference)} does not support '{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); + return DeserializeRunStepCodeInterpreterImageReference(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageReference.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageReference.cs new file mode 100644 index 0000000000000..847ae6405a581 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterImageReference.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterLogOutput.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterLogOutput.Serialization.cs new file mode 100644 index 0000000000000..6f4fe70a04cc1 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterLogOutput.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class RunStepCodeInterpreterLogOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterLogOutput)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("logs"u8); + writer.WriteStringValue(Logs); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterLogOutput(document.RootElement, options); + } + + internal static RunStepCodeInterpreterLogOutput DeserializeRunStepCodeInterpreterLogOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string logs = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRunStepCodeInterpreterLogOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterLogOutput)} does not support '{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); + return DeserializeRunStepCodeInterpreterLogOutput(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterLogOutput.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterLogOutput.cs new file mode 100644 index 0000000000000..beb90e4f37b78 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterLogOutput.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCall.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCall.Serialization.cs new file mode 100644 index 0000000000000..d6a33012f48ca --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCall.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepCodeInterpreterToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCall)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("codeInterpreter"u8); + writer.WriteObjectValue(InternalDetails); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterToolCall(document.RootElement, options); + } + + internal static RunStepCodeInterpreterToolCall DeserializeRunStepCodeInterpreterToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCodeInterpreterToolCallDetails codeInterpreter = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("codeInterpreter"u8)) + { + codeInterpreter = InternalCodeInterpreterToolCallDetails.DeserializeInternalCodeInterpreterToolCallDetails(property.Value); + 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRunStepCodeInterpreterToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCall)} does not support '{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); + return DeserializeRunStepCodeInterpreterToolCall(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCall.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCall.cs new file mode 100644 index 0000000000000..c7e5750d2308d --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCall.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs new file mode 100644 index 0000000000000..d30a6d0daf29d --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCallOutput.Serialization.cs @@ -0,0 +1,128 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownRunStepCodeInterpreterToolCallOutput))] + internal partial class RunStepCodeInterpreterToolCallOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement, options); + } + + internal static RunStepCodeInterpreterToolCallOutput DeserializeRunStepCodeInterpreterToolCallOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "logs": return RunStepCodeInterpreterLogOutput.DeserializeRunStepCodeInterpreterLogOutput(element); + case "image": return RunStepCodeInterpreterImageOutput.DeserializeRunStepCodeInterpreterImageOutput(element); + } + } + return UnknownRunStepCodeInterpreterToolCallOutput.DeserializeUnknownRunStepCodeInterpreterToolCallOutput(element); + } + + 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 '{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); + return DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support '{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); + return DeserializeRunStepCodeInterpreterToolCallOutput(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCallOutput.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCodeInterpreterToolCallOutput.cs new file mode 100644 index 0000000000000..3bbf42da2ab68 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDetails.Serialization.cs new file mode 100644 index 0000000000000..d705bccfa2f27 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDetails.Serialization.cs @@ -0,0 +1,128 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownRunStepDetails))] + public partial class RunStepDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDetails(document.RootElement, options); + } + + internal static RunStepDetails DeserializeRunStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "message_creation": return RunStepMessageCreationDetails.DeserializeRunStepMessageCreationDetails(element); + case "tool_calls": return RunStepToolCallDetails.DeserializeRunStepToolCallDetails(element); + } + } + return UnknownRunStepDetails.DeserializeUnknownRunStepDetails(element); + } + + 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 '{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); + return DeserializeRunStepDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDetails)} does not support '{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); + return DeserializeRunStepDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDetails.cs new file mode 100644 index 0000000000000..a483afac69d6f --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepError.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepError.Serialization.cs new file mode 100644 index 0000000000000..889e02dfe650e --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepError.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepError)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepError(document.RootElement, options); + } + + internal static RunStepError DeserializeRunStepError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepErrorCode code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRunStepError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepError)} does not support '{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); + return DeserializeRunStepError(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepError.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepError.cs new file mode 100644 index 0000000000000..78b64982ff48b --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepError.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepErrorCode.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepErrorCode.cs new file mode 100644 index 0000000000000..394710484faf4 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFunctionToolCall.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFunctionToolCall.Serialization.cs new file mode 100644 index 0000000000000..73adb9f801b2f --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFunctionToolCall.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepFunctionToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepFunctionToolCall)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(InternalDetails); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepFunctionToolCall(document.RootElement, options); + } + + internal static RunStepFunctionToolCall DeserializeRunStepFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalRunStepFunctionToolCallDetails function = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("function"u8)) + { + function = InternalRunStepFunctionToolCallDetails.DeserializeInternalRunStepFunctionToolCallDetails(property.Value); + 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRunStepFunctionToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepFunctionToolCall)} does not support '{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); + return DeserializeRunStepFunctionToolCall(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFunctionToolCall.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFunctionToolCall.cs new file mode 100644 index 0000000000000..3571cf490c018 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFunctionToolCall.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationDetails.Serialization.cs new file mode 100644 index 0000000000000..7fad907d653a8 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationDetails.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepMessageCreationDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepMessageCreationDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("messageCreation"u8); + writer.WriteObjectValue(MessageCreation); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepMessageCreationDetails(document.RootElement, options); + } + + internal static RunStepMessageCreationDetails DeserializeRunStepMessageCreationDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepMessageCreationReference messageCreation = default; + RunStepType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messageCreation"u8)) + { + messageCreation = RunStepMessageCreationReference.DeserializeRunStepMessageCreationReference(property.Value); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new RunStepType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRunStepMessageCreationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepMessageCreationDetails)} does not support '{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); + return DeserializeRunStepMessageCreationDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationDetails.cs new file mode 100644 index 0000000000000..526bd1c6e1750 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationDetails.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationReference.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationReference.Serialization.cs new file mode 100644 index 0000000000000..cd172ec2c3f46 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationReference.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepMessageCreationReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepMessageCreationReference)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("messageId"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepMessageCreationReference(document.RootElement, options); + } + + internal static RunStepMessageCreationReference DeserializeRunStepMessageCreationReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string messageId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messageId"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRunStepMessageCreationReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepMessageCreationReference)} does not support '{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); + return DeserializeRunStepMessageCreationReference(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationReference.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationReference.cs new file mode 100644 index 0000000000000..55263d6961df4 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepMessageCreationReference.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepObject.cs new file mode 100644 index 0000000000000..926e85797daeb --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.Serialization.cs new file mode 100644 index 0000000000000..6b5c4a008556a --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.Serialization.cs @@ -0,0 +1,163 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepRetrievalToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepRetrievalToolCall)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("retrieval"u8); + writer.WriteStartObject(); + foreach (var item in Retrieval) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepRetrievalToolCall 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(RunStepRetrievalToolCall)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepRetrievalToolCall(document.RootElement, options); + } + + internal static RunStepRetrievalToolCall DeserializeRunStepRetrievalToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary retrieval = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("retrieval"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + retrieval = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new RunStepRetrievalToolCall(type, id, serializedAdditionalRawData, retrieval); + } + + 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(RunStepRetrievalToolCall)} does not support '{options.Format}' format."); + } + } + + RunStepRetrievalToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepRetrievalToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepRetrievalToolCall)} does not support '{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 RunStepRetrievalToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepRetrievalToolCall(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.cs new file mode 100644 index 0000000000000..1360bcef0c752 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// A record of a call to a retrieval tool, issued by the model in evaluation of a defined tool, that represents + /// executed retrieval actions. + /// + public partial class RunStepRetrievalToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// The key/value pairs produced by the retrieval tool. + /// or is null. + internal RunStepRetrievalToolCall(string id, IReadOnlyDictionary retrieval) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(retrieval, nameof(retrieval)); + + Type = "retrieval"; + Retrieval = retrieval; + } + + /// 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 key/value pairs produced by the retrieval tool. + internal RunStepRetrievalToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary retrieval) : base(type, id, serializedAdditionalRawData) + { + Retrieval = retrieval; + } + + /// Initializes a new instance of for deserialization. + internal RunStepRetrievalToolCall() + { + } + + /// The key/value pairs produced by the retrieval tool. + public IReadOnlyDictionary Retrieval { get; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepStatus.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepStatus.cs new file mode 100644 index 0000000000000..3422c984e9a41 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.Serialization.cs new file mode 100644 index 0000000000000..abf3068f583ad --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.Serialization.cs @@ -0,0 +1,131 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownRunStepToolCall))] + public partial class RunStepToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepToolCall(document.RootElement, options); + } + + internal static RunStepToolCall DeserializeRunStepToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "code_interpreter": return RunStepCodeInterpreterToolCall.DeserializeRunStepCodeInterpreterToolCall(element); + case "retrieval": return RunStepRetrievalToolCall.DeserializeRunStepRetrievalToolCall(element); + case "function": return RunStepFunctionToolCall.DeserializeRunStepFunctionToolCall(element); + } + } + return UnknownRunStepToolCall.DeserializeUnknownRunStepToolCall(element); + } + + 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 '{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); + return DeserializeRunStepToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support '{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); + return DeserializeRunStepToolCall(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.cs new file mode 100644 index 0000000000000..e6f8e7320f8a4 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.Serialization.cs new file mode 100644 index 0000000000000..c5f8b9151e42b --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.Serialization.cs @@ -0,0 +1,154 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepToolCallDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepToolCallDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("toolCalls"u8); + writer.WriteStartArray(); + foreach (var item in ToolCalls) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepToolCallDetails(document.RootElement, options); + } + + internal static RunStepToolCallDetails DeserializeRunStepToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList toolCalls = default; + RunStepType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("toolCalls"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RunStepToolCall.DeserializeRunStepToolCall(item)); + } + toolCalls = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = new RunStepType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeRunStepToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepToolCallDetails)} does not support '{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); + return DeserializeRunStepToolCallDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.cs new file mode 100644 index 0000000000000..6ff45b4316891 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.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; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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. + /// 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. + 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepType.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/RunStepType.cs new file mode 100644 index 0000000000000..d532ee6ba08fe --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsAction.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsAction.Serialization.cs new file mode 100644 index 0000000000000..aa4303daa8cfc --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsAction.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class SubmitToolOutputsAction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubmitToolOutputsAction)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("submitToolOutputs"u8); + writer.WriteObjectValue(InternalDetails); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubmitToolOutputsAction(document.RootElement, options); + } + + internal static SubmitToolOutputsAction DeserializeSubmitToolOutputsAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalSubmitToolOutputsDetails submitToolOutputs = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("submitToolOutputs"u8)) + { + submitToolOutputs = InternalSubmitToolOutputsDetails.DeserializeInternalSubmitToolOutputsDetails(property.Value); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeSubmitToolOutputsAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubmitToolOutputsAction)} does not support '{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); + return DeserializeSubmitToolOutputsAction(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsAction.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsAction.cs new file mode 100644 index 0000000000000..73dcf47eeebeb --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsAction.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The details for required tool calls that must be submitted for an assistant 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs new file mode 100644 index 0000000000000..a15d485d15b69 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs @@ -0,0 +1,146 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class SubmitToolOutputsToRunRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubmitToolOutputsToRunRequest)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("toolOutputs"u8); + writer.WriteStartArray(); + foreach (var item in ToolOutputs) + { + writer.WriteObjectValue(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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubmitToolOutputsToRunRequest(document.RootElement, options); + } + + internal static SubmitToolOutputsToRunRequest DeserializeSubmitToolOutputsToRunRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList toolOutputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("toolOutputs"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ToolOutput.DeserializeToolOutput(item)); + } + toolOutputs = array; + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new SubmitToolOutputsToRunRequest(toolOutputs, 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 '{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); + return DeserializeSubmitToolOutputsToRunRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubmitToolOutputsToRunRequest)} does not support '{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); + return DeserializeSubmitToolOutputsToRunRequest(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.cs new file mode 100644 index 0000000000000..8758e67f46324 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.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; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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 . + /// The list of tool outputs requested by tool calls from the specified run. + /// is null. + public SubmitToolOutputsToRunRequest(IEnumerable toolOutputs) + { + Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + + ToolOutputs = toolOutputs.ToList(); + } + + /// Initializes a new instance of . + /// The list of tool outputs requested by tool calls from the specified run. + /// Keeps track of any properties unknown to the library. + internal SubmitToolOutputsToRunRequest(IList toolOutputs, IDictionary serializedAdditionalRawData) + { + ToolOutputs = toolOutputs; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SubmitToolOutputsToRunRequest() + { + } + + /// The list of tool outputs requested by tool calls from the specified run. + public IList ToolOutputs { get; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatus.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatus.Serialization.cs new file mode 100644 index 0000000000000..a75f90da2f1c2 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatus.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class ThreadDeletionStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadDeletionStatus)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadDeletionStatus(document.RootElement, options); + } + + internal static ThreadDeletionStatus DeserializeThreadDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + ThreadDeletionStatusObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeThreadDeletionStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadDeletionStatus)} does not support '{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); + return DeserializeThreadDeletionStatus(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatus.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatus.cs new file mode 100644 index 0000000000000..9a7016bc025b8 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatus.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatusObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadDeletionStatusObject.cs new file mode 100644 index 0000000000000..d29c8eb61d1a1 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.Serialization.cs new file mode 100644 index 0000000000000..f2d2ab671996c --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.Serialization.cs @@ -0,0 +1,202 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class ThreadInitializationMessage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadInitializationMessage)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("fileIds"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ThreadInitializationMessage 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(ThreadInitializationMessage)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadInitializationMessage(document.RootElement, options); + } + + internal static ThreadInitializationMessage DeserializeThreadInitializationMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageRole role = default; + string content = default; + Optional> fileIds = default; + Optional> metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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 = property.Value.GetString(); + continue; + } + if (property.NameEquals("fileIds"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("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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ThreadInitializationMessage(role, content, Optional.ToList(fileIds), Optional.ToDictionary(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(ThreadInitializationMessage)} does not support '{options.Format}' format."); + } + } + + ThreadInitializationMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeThreadInitializationMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadInitializationMessage)} does not support '{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 ThreadInitializationMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeThreadInitializationMessage(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.cs new file mode 100644 index 0000000000000..13fd8b6cc1e29 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// A single message within an assistant thread, as provided during that thread's creation for its initial state. + public partial class ThreadInitializationMessage + { + /// + /// 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 associated with the assistant thread message. Currently, only 'user' is supported when providing initial messages to a new thread. + /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via a separate call to the create message API. + /// is null. + public ThreadInitializationMessage(MessageRole role, string content) + { + Argument.AssertNotNull(content, nameof(content)); + + Role = role; + Content = content; + FileIds = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The role associated with the assistant thread message. Currently, only 'user' is supported when providing initial messages to a new thread. + /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via a separate call to the create message API. + /// + /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can + /// access files. + /// + /// 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 ThreadInitializationMessage(MessageRole role, string content, IList fileIds, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Role = role; + Content = content; + FileIds = fileIds; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ThreadInitializationMessage() + { + } + + /// The role associated with the assistant thread message. Currently, only 'user' is supported when providing initial messages to a new thread. + public MessageRole Role { get; } + /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via a separate call to the create message API. + public string Content { get; } + /// + /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can + /// access files. + /// + public IList FileIds { 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 IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.Serialization.cs new file mode 100644 index 0000000000000..9ef1e3b93aff9 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.Serialization.cs @@ -0,0 +1,257 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class ThreadMessage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadMessage)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("createdAt"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("threadId"u8); + writer.WriteStringValue(ThreadId); + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in ContentItems) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(AssistantId)) + { + writer.WritePropertyName("assistantId"u8); + writer.WriteStringValue(AssistantId); + } + if (Optional.IsDefined(RunId)) + { + writer.WritePropertyName("runId"u8); + writer.WriteStringValue(RunId); + } + writer.WritePropertyName("fileIds"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadMessage(document.RootElement, options); + } + + internal static ThreadMessage DeserializeThreadMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + ThreadMessageObject @object = default; + DateTimeOffset createdAt = default; + string threadId = default; + MessageRole role = default; + IReadOnlyList content = default; + Optional assistantId = default; + Optional runId = default; + IReadOnlyList fileIds = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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("createdAt"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("threadId"u8)) + { + threadId = property.Value.GetString(); + 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)); + } + content = array; + continue; + } + if (property.NameEquals("assistantId"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("runId"u8)) + { + runId = property.Value.GetString(); + continue; + } + if (property.NameEquals("fileIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ThreadMessage(id, @object, createdAt, threadId, role, content, assistantId.Value, runId.Value, fileIds, 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 '{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); + return DeserializeThreadMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadMessage)} does not support '{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); + return DeserializeThreadMessage(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.cs new file mode 100644 index 0000000000000..3897c00397e07 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// A single, existing message within an assistant 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 role associated with the assistant thread message. + /// The list of content items associated with the assistant thread message. + /// + /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can + /// access files. + /// + /// 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, MessageRole role, IEnumerable contentItems, IEnumerable fileIds, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(threadId, nameof(threadId)); + Argument.AssertNotNull(contentItems, nameof(contentItems)); + Argument.AssertNotNull(fileIds, nameof(fileIds)); + + Id = id; + CreatedAt = createdAt; + ThreadId = threadId; + Role = role; + ContentItems = contentItems.ToList(); + FileIds = fileIds.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 role associated with the assistant thread message. + /// The list of content items associated with the assistant thread message. + /// If applicable, the ID of the assistant that authored this message. + /// If applicable, the ID of the run associated with the authoring of this message. + /// + /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can + /// access files. + /// + /// 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, MessageRole role, IReadOnlyList contentItems, string assistantId, string runId, IReadOnlyList fileIds, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + ThreadId = threadId; + Role = role; + ContentItems = contentItems; + AssistantId = assistantId; + RunId = runId; + FileIds = fileIds; + 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 role associated with the assistant thread message. + public MessageRole Role { get; } + /// + /// The list of content items associated with the assistant 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 assistant 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 file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can + /// access files. + /// + public IReadOnlyList FileIds { 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessageObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessageObject.cs new file mode 100644 index 0000000000000..176be72b3049e --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.Serialization.cs new file mode 100644 index 0000000000000..e42e94dd7f184 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.Serialization.cs @@ -0,0 +1,402 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class ThreadRun : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadRun)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("threadId"u8); + writer.WriteStringValue(ThreadId); + writer.WritePropertyName("assistantId"u8); + writer.WriteStringValue(AssistantId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsDefined(RequiredAction)) + { + if (RequiredAction != null) + { + writer.WritePropertyName("requiredAction"u8); + writer.WriteObjectValue(RequiredAction); + } + else + { + writer.WriteNull("requiredAction"); + } + } + if (LastError != null) + { + writer.WritePropertyName("lastError"u8); + writer.WriteObjectValue(LastError); + } + else + { + writer.WriteNull("lastError"); + } + 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); + } + writer.WriteEndArray(); + writer.WritePropertyName("fileIds"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("createdAt"u8); + writer.WriteNumberValue(CreatedAt, "U"); + if (ExpiresAt != null) + { + writer.WritePropertyName("expiresAt"u8); + writer.WriteStringValue(ExpiresAt.Value, "O"); + } + else + { + writer.WriteNull("expiresAt"); + } + if (StartedAt != null) + { + writer.WritePropertyName("startedAt"u8); + writer.WriteStringValue(StartedAt.Value, "O"); + } + else + { + writer.WriteNull("startedAt"); + } + if (CompletedAt != null) + { + writer.WritePropertyName("completedAt"u8); + writer.WriteStringValue(CompletedAt.Value, "O"); + } + else + { + writer.WriteNull("completedAt"); + } + if (CancelledAt != null) + { + writer.WritePropertyName("cancelledAt"u8); + writer.WriteStringValue(CancelledAt.Value, "O"); + } + else + { + writer.WriteNull("cancelledAt"); + } + if (FailedAt != null) + { + writer.WritePropertyName("failedAt"u8); + writer.WriteStringValue(FailedAt.Value, "O"); + } + else + { + writer.WriteNull("failedAt"); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadRun(document.RootElement, options); + } + + internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + ThreadRunObject @object = default; + string threadId = default; + string assistantId = default; + RunStatus status = default; + Optional requiredAction = default; + RunError lastError = default; + string model = default; + string instructions = default; + IReadOnlyList tools = default; + IReadOnlyList fileIds = default; + DateTimeOffset createdAt = default; + DateTimeOffset? expiresAt = default; + DateTimeOffset? startedAt = default; + DateTimeOffset? completedAt = default; + DateTimeOffset? cancelledAt = default; + DateTimeOffset? failedAt = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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("threadId"u8)) + { + threadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("assistantId"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new RunStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("requiredAction"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + requiredAction = null; + continue; + } + requiredAction = RequiredAction.DeserializeRequiredAction(property.Value); + continue; + } + if (property.NameEquals("lastError"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastError = null; + continue; + } + lastError = RunError.DeserializeRunError(property.Value); + 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)); + } + tools = array; + continue; + } + if (property.NameEquals("fileIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (property.NameEquals("createdAt"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("expiresAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + expiresAt = null; + continue; + } + expiresAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("startedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + startedAt = null; + continue; + } + startedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + completedAt = null; + continue; + } + completedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("cancelledAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + cancelledAt = null; + continue; + } + cancelledAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("failedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + failedAt = null; + continue; + } + failedAt = property.Value.GetDateTimeOffset("O"); + 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ThreadRun(id, @object, threadId, assistantId, status, requiredAction.Value, lastError, model, instructions, tools, fileIds, createdAt, expiresAt, startedAt, completedAt, cancelledAt, failedAt, 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(ThreadRun)} does not support '{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); + return DeserializeThreadRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadRun)} does not support '{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); + return DeserializeThreadRun(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.cs new file mode 100644 index 0000000000000..560e77ca8efa0 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Data representing a single evaluation run of an assistant 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 assistant associated with the thread this run was performed against. + /// The status of the assistant thread run. + /// The last error, if any, encountered by this assistant thread run. + /// The ID of the model to use. + /// The overridden system instructions used for this assistant thread run. + /// The overridden enabled tools used for this assistant thread run. + /// A list of attached file IDs, ordered by creation date in ascending order. + /// 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. + /// 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 ThreadRun(string id, string threadId, string assistantId, RunStatus status, RunError lastError, string model, string instructions, IEnumerable tools, IEnumerable fileIds, DateTimeOffset createdAt, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IReadOnlyDictionary metadata) + { + 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)); + Argument.AssertNotNull(fileIds, nameof(fileIds)); + + Id = id; + ThreadId = threadId; + AssistantId = assistantId; + Status = status; + LastError = lastError; + Model = model; + Instructions = instructions; + Tools = tools.ToList(); + FileIds = fileIds.ToList(); + CreatedAt = createdAt; + ExpiresAt = expiresAt; + StartedAt = startedAt; + 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'. + /// The ID of the thread associated with this run. + /// The ID of the assistant associated with the thread this run was performed against. + /// The status of the assistant thread run. + /// The details of the action required for the assistant thread run to continue. + /// The last error, if any, encountered by this assistant thread run. + /// The ID of the model to use. + /// The overridden system instructions used for this assistant thread run. + /// The overridden enabled tools used for this assistant thread run. + /// A list of attached file IDs, ordered by creation date in ascending order. + /// 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. + /// 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 ThreadRun(string id, ThreadRunObject @object, string threadId, string assistantId, RunStatus status, RequiredAction requiredAction, RunError lastError, string model, string instructions, IReadOnlyList tools, IReadOnlyList fileIds, DateTimeOffset createdAt, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + ThreadId = threadId; + AssistantId = assistantId; + Status = status; + RequiredAction = requiredAction; + LastError = lastError; + Model = model; + Instructions = instructions; + Tools = tools; + FileIds = fileIds; + CreatedAt = createdAt; + ExpiresAt = expiresAt; + StartedAt = startedAt; + CompletedAt = completedAt; + CancelledAt = cancelledAt; + FailedAt = failedAt; + Metadata = metadata; + _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 assistant associated with the thread this run was performed against. + public string AssistantId { get; } + /// The status of the assistant thread run. + public RunStatus Status { get; } + /// + /// The details of the action required for the assistant 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 assistant thread run. + public RunError LastError { get; } + /// The ID of the model to use. + public string Model { get; } + /// The overridden system instructions used for this assistant thread run. + public string Instructions { get; } + /// + /// The overridden enabled tools used for this assistant 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; } + /// A list of attached file IDs, ordered by creation date in ascending order. + public IReadOnlyList FileIds { 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; } + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRunObject.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRunObject.cs new file mode 100644 index 0000000000000..718305856ef77 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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 string 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?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.Serialization.cs new file mode 100644 index 0000000000000..2effa166cbe0a --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.Serialization.cs @@ -0,0 +1,129 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownToolDefinition))] + public partial class ToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolDefinition)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolDefinition(document.RootElement, options); + } + + internal static ToolDefinition DeserializeToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "code_interpreter": return CodeInterpreterToolDefinition.DeserializeCodeInterpreterToolDefinition(element); + case "retrieval": return RetrievalToolDefinition.DeserializeRetrievalToolDefinition(element); + case "function": return FunctionToolDefinition.DeserializeFunctionToolDefinition(element); + } + } + return UnknownToolDefinition.DeserializeUnknownToolDefinition(element); + } + + 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 '{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); + return DeserializeToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolDefinition)} does not support '{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); + return DeserializeToolDefinition(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.cs new file mode 100644 index 0000000000000..d2c10bd1ac3c7 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// + /// An abstract representation of an input tool definition that an assistant 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolOutput.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolOutput.Serialization.cs new file mode 100644 index 0000000000000..138514de21448 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolOutput.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class ToolOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolOutput)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ToolCallId)) + { + writer.WritePropertyName("toolCallId"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolOutput(document.RootElement, options); + } + + internal static ToolOutput DeserializeToolOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional toolCallId = default; + Optional output = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("toolCallId"u8)) + { + toolCallId = property.Value.GetString(); + continue; + } + if (property.NameEquals("output"u8)) + { + output = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new ToolOutput(toolCallId.Value, output.Value, 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 '{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); + return DeserializeToolOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolOutput)} does not support '{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); + return DeserializeToolOutput(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolOutput.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/ToolOutput.cs new file mode 100644 index 0000000000000..dea8cd8b47856 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageContent.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageContent.Serialization.cs new file mode 100644 index 0000000000000..6eb981cd658dd --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageContent.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownMessageContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageContent)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUnknownMessageContent(document.RootElement, options); + } + + internal static UnknownMessageContent DeserializeUnknownMessageContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeUnknownMessageContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageContent)} does not support '{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); + return DeserializeUnknownMessageContent(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageContent.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageContent.cs new file mode 100644 index 0000000000000..b97dd8996dda8 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.Serialization.cs new file mode 100644 index 0000000000000..0e2974890273f --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownMessageTextAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + writer.WritePropertyName("startIndex"u8); + writer.WriteNumberValue(StartIndex); + writer.WritePropertyName("endIndex"u8); + writer.WriteNumberValue(EndIndex); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUnknownMessageTextAnnotation(document.RootElement, options); + } + + internal static UnknownMessageTextAnnotation DeserializeUnknownMessageTextAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + string text = default; + int startIndex = default; + int endIndex = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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 (property.NameEquals("startIndex"u8)) + { + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("endIndex"u8)) + { + endIndex = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new UnknownMessageTextAnnotation(type, text, startIndex, endIndex, 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 '{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); + return DeserializeUnknownMessageTextAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageTextAnnotation)} does not support '{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); + return DeserializeUnknownMessageTextAnnotation(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.cs new file mode 100644 index 0000000000000..707b991383074 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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. + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + /// Keeps track of any properties unknown to the library. + internal UnknownMessageTextAnnotation(string type, string text, int startIndex, int endIndex, IDictionary serializedAdditionalRawData) : base(type, text, startIndex, endIndex, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownMessageTextAnnotation() + { + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredAction.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredAction.Serialization.cs new file mode 100644 index 0000000000000..c0ffdcc2acc65 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredAction.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownRequiredAction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredAction)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUnknownRequiredAction(document.RootElement, options); + } + + internal static UnknownRequiredAction DeserializeUnknownRequiredAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeUnknownRequiredAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredAction)} does not support '{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); + return DeserializeUnknownRequiredAction(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredAction.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredAction.cs new file mode 100644 index 0000000000000..6d2d70960de51 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredToolCall.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredToolCall.Serialization.cs new file mode 100644 index 0000000000000..231968ca550c0 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredToolCall.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownRequiredToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUnknownRequiredToolCall(document.RootElement, options); + } + + internal static UnknownRequiredToolCall DeserializeUnknownRequiredToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeUnknownRequiredToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RequiredToolCall)} does not support '{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); + return DeserializeUnknownRequiredToolCall(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredToolCall.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRequiredToolCall.cs new file mode 100644 index 0000000000000..bd858412c4753 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.Serialization.cs new file mode 100644 index 0000000000000..4feadd32d6b9f --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownRunStepCodeInterpreterToolCallOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUnknownRunStepCodeInterpreterToolCallOutput(document.RootElement, options); + } + + internal static UnknownRunStepCodeInterpreterToolCallOutput DeserializeUnknownRunStepCodeInterpreterToolCallOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeUnknownRunStepCodeInterpreterToolCallOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterToolCallOutput)} does not support '{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); + return DeserializeUnknownRunStepCodeInterpreterToolCallOutput(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepCodeInterpreterToolCallOutput.cs new file mode 100644 index 0000000000000..1fe645994c78d --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDetails.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDetails.Serialization.cs new file mode 100644 index 0000000000000..ccce2282e66ee --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDetails.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownRunStepDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDetails)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUnknownRunStepDetails(document.RootElement, options); + } + + internal static UnknownRunStepDetails DeserializeUnknownRunStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new RunStepType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeUnknownRunStepDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDetails)} does not support '{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); + return DeserializeUnknownRunStepDetails(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDetails.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDetails.cs new file mode 100644 index 0000000000000..11d6cdeccbe7b --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepToolCall.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepToolCall.Serialization.cs new file mode 100644 index 0000000000000..a6c9281dd1c17 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepToolCall.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownRunStepToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUnknownRunStepToolCall(document.RootElement, options); + } + + internal static UnknownRunStepToolCall DeserializeUnknownRunStepToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeUnknownRunStepToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support '{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); + return DeserializeUnknownRunStepToolCall(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepToolCall.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepToolCall.cs new file mode 100644 index 0000000000000..dec47faffb6e7 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownToolDefinition.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownToolDefinition.Serialization.cs new file mode 100644 index 0000000000000..01fe6ce100ae4 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownToolDefinition.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.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolDefinition)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUnknownToolDefinition(document.RootElement, options); + } + + internal static UnknownToolDefinition DeserializeUnknownToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + 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 '{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); + return DeserializeUnknownToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolDefinition)} does not support '{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); + return DeserializeUnknownToolDefinition(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownToolDefinition.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UnknownToolDefinition.cs new file mode 100644 index 0000000000000..9d7f65acf52ca --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants +{ + /// 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/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.Serialization.cs new file mode 100644 index 0000000000000..505a56bcc760f --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class UpdateAssistantOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateAssistantOptions)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("fileIds"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + UpdateAssistantOptions 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(UpdateAssistantOptions)} does not support '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateAssistantOptions(document.RootElement, options); + } + + internal static UpdateAssistantOptions DeserializeUpdateAssistantOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional model = default; + Optional name = default; + Optional description = default; + Optional instructions = default; + Optional> tools = default; + Optional> fileIds = default; + Optional> metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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)); + } + tools = array; + continue; + } + if (property.NameEquals("fileIds"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("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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new UpdateAssistantOptions(model.Value, name.Value, description.Value, instructions.Value, Optional.ToList(tools), Optional.ToList(fileIds), Optional.ToDictionary(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(UpdateAssistantOptions)} does not support '{options.Format}' format."); + } + } + + UpdateAssistantOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeUpdateAssistantOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateAssistantOptions)} does not support '{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 UpdateAssistantOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUpdateAssistantOptions(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.cs new file mode 100644 index 0000000000000..d69298f5f65af --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The request details to use when modifying an existing assistant. + public partial class UpdateAssistantOptions + { + /// + /// 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 UpdateAssistantOptions() + { + Tools = new ChangeTrackingList(); + FileIds = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The ID of the model to use. + /// The modified name for the assistant to use. + /// The modified description for the assistant to use. + /// The modified system instructions for the new assistant to use. + /// The modified collection of tools to enable for the assistant. + /// The modified list of previously uploaded fileIDs to attach to the assistant. + /// 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 UpdateAssistantOptions(string model, string name, string description, string instructions, IList tools, IList fileIds, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Model = model; + Name = name; + Description = description; + Instructions = instructions; + Tools = tools; + FileIds = fileIds; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The ID of the model to use. + public string Model { get; set; } + /// The modified name for the assistant to use. + public string Name { get; set; } + /// The modified description for the assistant to use. + public string Description { get; set; } + /// The modified system instructions for the new assistant to use. + public string Instructions { get; set; } + /// + /// The modified collection of tools to enable for the assistant. + /// 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 IList Tools { get; } + /// The modified list of previously uploaded fileIDs to attach to the assistant. + public IList FileIds { 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 IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateMessageRequest.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateMessageRequest.Serialization.cs new file mode 100644 index 0000000000000..aac2c62a0ec44 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateMessageRequest.Serialization.cs @@ -0,0 +1,161 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UpdateMessageRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateMessageRequest)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateMessageRequest(document.RootElement, options); + } + + internal static UpdateMessageRequest DeserializeUpdateMessageRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new UpdateMessageRequest(Optional.ToDictionary(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(UpdateMessageRequest)} does not support '{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); + return DeserializeUpdateMessageRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateMessageRequest)} does not support '{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); + return DeserializeUpdateMessageRequest(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateMessageRequest.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateMessageRequest.cs new file mode 100644 index 0000000000000..ca29b11092ffe --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateMessageRequest.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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 . + public 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(IDictionary 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 IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateRunRequest.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateRunRequest.Serialization.cs new file mode 100644 index 0000000000000..79876c604db9c --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateRunRequest.Serialization.cs @@ -0,0 +1,161 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UpdateRunRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateRunRequest)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateRunRequest(document.RootElement, options); + } + + internal static UpdateRunRequest DeserializeUpdateRunRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new UpdateRunRequest(Optional.ToDictionary(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(UpdateRunRequest)} does not support '{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); + return DeserializeUpdateRunRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateRunRequest)} does not support '{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); + return DeserializeUpdateRunRequest(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateRunRequest.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateRunRequest.cs new file mode 100644 index 0000000000000..f152fd7158310 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateRunRequest.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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 . + public 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(IDictionary 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 IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.Serialization.cs new file mode 100644 index 0000000000000..cf64c90c76411 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.Serialization.cs @@ -0,0 +1,161 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UpdateThreadRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateThreadRequest(document.RootElement, options); + } + + internal static UpdateThreadRequest DeserializeUpdateThreadRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new UpdateThreadRequest(Optional.ToDictionary(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(UpdateThreadRequest)} does not support '{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); + return DeserializeUpdateThreadRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support '{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); + return DeserializeUpdateThreadRequest(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.cs new file mode 100644 index 0000000000000..8705af25b8279 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// 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 . + public UpdateThreadRequest() + { + 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 UpdateThreadRequest(IDictionary 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 IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UploadFileRequest.Serialization.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UploadFileRequest.Serialization.cs new file mode 100644 index 0000000000000..5fe1521da14f5 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UploadFileRequest.Serialization.cs @@ -0,0 +1,155 @@ +// 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; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UploadFileRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, new ModelReaderWriterOptions("W")); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UploadFileRequest)} does not support '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(Data.ToArray(), "D"); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + 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 '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUploadFileRequest(document.RootElement, options); + } + + internal static UploadFileRequest DeserializeUploadFileRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= new ModelReaderWriterOptions("W"); + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData file = default; + OpenAIFilePurpose purpose = default; + Optional filename = default; + IDictionary serializedAdditionalRawData = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file"u8)) + { + file = BinaryData.FromBytes(property.Value.GetBytesFromBase64("D")); + 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") + { + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = additionalPropertiesDictionary; + return new UploadFileRequest(file, purpose, filename.Value, 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(UploadFileRequest)} does not support '{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); + return DeserializeUploadFileRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UploadFileRequest)} does not support '{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 UploadFileRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUploadFileRequest(document.RootElement); + } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UploadFileRequest.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UploadFileRequest.cs new file mode 100644 index 0000000000000..7167d9b9b836b --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Generated/UploadFileRequest.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 Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The UploadFileRequest. + internal 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 (not filename) to upload. + /// The intended purpose of the file. + /// is null. + public UploadFileRequest(BinaryData data, OpenAIFilePurpose purpose) + { + Argument.AssertNotNull(data, nameof(data)); + + Data = data; + Purpose = purpose; + } + + /// Initializes a new instance of . + /// The file data (not filename) to upload. + /// The intended purpose of the file. + /// A filename to associate with the uploaded data. + /// Keeps track of any properties unknown to the library. + internal UploadFileRequest(BinaryData 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 (not filename) to upload. + /// + /// 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 Data { get; } + /// The intended purpose of the file. + public OpenAIFilePurpose Purpose { get; } + /// A filename to associate with the uploaded data. + public string Filename { get; set; } + } +} diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Properties/AssemblyInfo.cs b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..911082ed8d692 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/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.OpenAI.Assistants.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/openai/assistants/Azure.AI.OpenAI.Assistants/tests/Azure.AI.OpenAI.Assistants.Tests.csproj b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/tests/Azure.AI.OpenAI.Assistants.Tests.csproj new file mode 100644 index 0000000000000..f1a63fc86d85d --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/tests/Azure.AI.OpenAI.Assistants.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/tsp-location.yaml b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/tsp-location.yaml new file mode 100644 index 0000000000000..38ebdd7876cf9 --- /dev/null +++ b/sdk/openai/assistants/Azure.AI.OpenAI.Assistants/tsp-location.yaml @@ -0,0 +1,5 @@ +repo: Azure/azure-rest-api-specs +directory: specification/ai/OpenAI.Assistants +commit: a718913e51a489e2ed6fa6a5966e5291b8018435 +additionalDirectories: [] + diff --git a/sdk/openai/assistants/ci.yml b/sdk/openai/assistants/ci.yml new file mode 100644 index 0000000000000..c6f81c7646f59 --- /dev/null +++ b/sdk/openai/assistants/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/assistants + - sdk/assistants/ci.yml + - sdk/assistants/Azure.AI.OpenAI.Assistants + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/assistants + - sdk/assistants/ci.yml + - sdk/assistants/Azure.AI.OpenAI.Assistants + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: assistants + ArtifactName: packages + Artifacts: + - name: Azure.AI.OpenAI.Assistants + safeName: AzureAIOpenAIAssistants diff --git a/sdk/vision/Azure.AI.Vision.ImageAnalysis/src/Generated/ImageAnalysisResult.Serialization.cs b/sdk/vision/Azure.AI.Vision.ImageAnalysis/src/Generated/ImageAnalysisResult.Serialization.cs index 2fafe075fe9f1..4d87588bb6b5d 100644 --- a/sdk/vision/Azure.AI.Vision.ImageAnalysis/src/Generated/ImageAnalysisResult.Serialization.cs +++ b/sdk/vision/Azure.AI.Vision.ImageAnalysis/src/Generated/ImageAnalysisResult.Serialization.cs @@ -29,12 +29,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartObject(); if (Optional.IsDefined(Caption)) { - writer.WritePropertyName("captionResult"u8); + writer.WritePropertyName("caption"u8); writer.WriteObjectValue(Caption); } if (Optional.IsDefined(DenseCaptions)) { - writer.WritePropertyName("denseCaptionsResult"u8); + writer.WritePropertyName("denseCaptions"u8); writer.WriteObjectValue(DenseCaptions); } writer.WritePropertyName("metadata"u8); @@ -43,27 +43,27 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri writer.WriteStringValue(ModelVersion); if (Optional.IsDefined(Objects)) { - writer.WritePropertyName("objectsResult"u8); + writer.WritePropertyName("objects"u8); writer.WriteObjectValue(Objects); } if (Optional.IsDefined(People)) { - writer.WritePropertyName("peopleResult"u8); + writer.WritePropertyName("people"u8); writer.WriteObjectValue(People); } if (Optional.IsDefined(Read)) { - writer.WritePropertyName("readResult"u8); + writer.WritePropertyName("read"u8); writer.WriteObjectValue(Read); } if (Optional.IsDefined(SmartCrops)) { - writer.WritePropertyName("smartCropsResult"u8); + writer.WritePropertyName("smartCrops"u8); writer.WriteObjectValue(SmartCrops); } if (Optional.IsDefined(Tags)) { - writer.WritePropertyName("tagsResult"u8); + writer.WritePropertyName("tags"u8); writer.WriteObjectValue(Tags); } if (options.Format != "W" && _serializedAdditionalRawData != null) @@ -104,35 +104,35 @@ internal static ImageAnalysisResult DeserializeImageAnalysisResult(JsonElement e { return null; } - Optional captionResult = default; - Optional denseCaptionsResult = default; + Optional caption = default; + Optional denseCaptions = default; ImageMetadata metadata = default; string modelVersion = default; - Optional objectsResult = default; - Optional peopleResult = default; - Optional readResult = default; - Optional smartCropsResult = default; - Optional tagsResult = default; + Optional objects = default; + Optional people = default; + Optional read = default; + Optional smartCrops = default; + Optional tags = default; IDictionary serializedAdditionalRawData = default; Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("captionResult"u8)) + if (property.NameEquals("caption"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - captionResult = CaptionResult.DeserializeCaptionResult(property.Value); + caption = CaptionResult.DeserializeCaptionResult(property.Value); continue; } - if (property.NameEquals("denseCaptionsResult"u8)) + if (property.NameEquals("denseCaptions"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - denseCaptionsResult = DenseCaptionsResult.DeserializeDenseCaptionsResult(property.Value); + denseCaptions = DenseCaptionsResult.DeserializeDenseCaptionsResult(property.Value); continue; } if (property.NameEquals("metadata"u8)) @@ -145,49 +145,49 @@ internal static ImageAnalysisResult DeserializeImageAnalysisResult(JsonElement e modelVersion = property.Value.GetString(); continue; } - if (property.NameEquals("objectsResult"u8)) + if (property.NameEquals("objects"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - objectsResult = ObjectsResult.DeserializeObjectsResult(property.Value); + objects = ObjectsResult.DeserializeObjectsResult(property.Value); continue; } - if (property.NameEquals("peopleResult"u8)) + if (property.NameEquals("people"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - peopleResult = PeopleResult.DeserializePeopleResult(property.Value); + people = PeopleResult.DeserializePeopleResult(property.Value); continue; } - if (property.NameEquals("readResult"u8)) + if (property.NameEquals("read"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - readResult = ReadResult.DeserializeReadResult(property.Value); + read = ReadResult.DeserializeReadResult(property.Value); continue; } - if (property.NameEquals("smartCropsResult"u8)) + if (property.NameEquals("smartCrops"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - smartCropsResult = SmartCropsResult.DeserializeSmartCropsResult(property.Value); + smartCrops = SmartCropsResult.DeserializeSmartCropsResult(property.Value); continue; } - if (property.NameEquals("tagsResult"u8)) + if (property.NameEquals("tags"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - tagsResult = TagsResult.DeserializeTagsResult(property.Value); + tags = TagsResult.DeserializeTagsResult(property.Value); continue; } if (options.Format != "W") @@ -196,7 +196,7 @@ internal static ImageAnalysisResult DeserializeImageAnalysisResult(JsonElement e } } serializedAdditionalRawData = additionalPropertiesDictionary; - return new ImageAnalysisResult(captionResult.Value, denseCaptionsResult.Value, metadata, modelVersion, objectsResult.Value, peopleResult.Value, readResult.Value, smartCropsResult.Value, tagsResult.Value, serializedAdditionalRawData); + return new ImageAnalysisResult(caption.Value, denseCaptions.Value, metadata, modelVersion, objects.Value, people.Value, read.Value, smartCrops.Value, tags.Value, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/vision/Azure.AI.Vision.ImageAnalysis/src/Generated/ImageBoundingBox.Serialization.cs b/sdk/vision/Azure.AI.Vision.ImageAnalysis/src/Generated/ImageBoundingBox.Serialization.cs index 954ce6b94d497..93210ce1d9b96 100644 --- a/sdk/vision/Azure.AI.Vision.ImageAnalysis/src/Generated/ImageBoundingBox.Serialization.cs +++ b/sdk/vision/Azure.AI.Vision.ImageAnalysis/src/Generated/ImageBoundingBox.Serialization.cs @@ -31,9 +31,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter writer.WriteNumberValue(X); writer.WritePropertyName("y"u8); writer.WriteNumberValue(Y); - writer.WritePropertyName("w"u8); + writer.WritePropertyName("width"u8); writer.WriteNumberValue(Width); - writer.WritePropertyName("h"u8); + writer.WritePropertyName("height"u8); writer.WriteNumberValue(Height); if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -75,8 +75,8 @@ internal static ImageBoundingBox DeserializeImageBoundingBox(JsonElement element } int x = default; int y = default; - int w = default; - int h = default; + int width = default; + int height = default; IDictionary serializedAdditionalRawData = default; Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -91,14 +91,14 @@ internal static ImageBoundingBox DeserializeImageBoundingBox(JsonElement element y = property.Value.GetInt32(); continue; } - if (property.NameEquals("w"u8)) + if (property.NameEquals("width"u8)) { - w = property.Value.GetInt32(); + width = property.Value.GetInt32(); continue; } - if (property.NameEquals("h"u8)) + if (property.NameEquals("height"u8)) { - h = property.Value.GetInt32(); + height = property.Value.GetInt32(); continue; } if (options.Format != "W") @@ -107,7 +107,7 @@ internal static ImageBoundingBox DeserializeImageBoundingBox(JsonElement element } } serializedAdditionalRawData = additionalPropertiesDictionary; - return new ImageBoundingBox(x, y, w, h, serializedAdditionalRawData); + return new ImageBoundingBox(x, y, width, height, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/vision/Azure.AI.Vision.ImageAnalysis/tsp-location.yaml b/sdk/vision/Azure.AI.Vision.ImageAnalysis/tsp-location.yaml index 5f1df6356746d..56c02bb6da879 100644 --- a/sdk/vision/Azure.AI.Vision.ImageAnalysis/tsp-location.yaml +++ b/sdk/vision/Azure.AI.Vision.ImageAnalysis/tsp-location.yaml @@ -1,6 +1,5 @@ -directory: specification/ai/ImageAnalysis/ -additionalDirectories: [] repo: Azure/azure-rest-api-specs -commit: 3cf7400ba3d65978bef86e9c4197a5e7f7bf5277 - +directory: specification/ai/ImageAnalysis +commit: a718913e51a489e2ed6fa6a5966e5291b8018435 +additionalDirectories: []