From 17b5cdcf4dec1f201585c08e5e29194f07e62a0e Mon Sep 17 00:00:00 2001 From: Jayant Kumar Date: Fri, 9 May 2025 01:58:11 +0530 Subject: [PATCH 1/6] Initial commit of Agents Library 1DP --- eng/versioning/version_client.txt | 1 + .../azure-ai-agents-persistent/CHANGELOG.md | 13 + sdk/ai/azure-ai-agents-persistent/README.md | 78 + sdk/ai/azure-ai-agents-persistent/assets.json | 1 + sdk/ai/azure-ai-agents-persistent/pom.xml | 78 + .../persistent/AgentsServiceVersion.java | 50 + .../agents/persistent/FilesAsyncClient.java | 346 +++ .../ai/agents/persistent/FilesClient.java | 336 +++ .../persistent/MessagesAsyncClient.java | 643 +++++ .../ai/agents/persistent/MessagesClient.java | 609 +++++ ...istentAgentsAdministrationAsyncClient.java | 998 ++++++++ .../PersistentAgentsAdministrationClient.java | 961 ++++++++ ...tentAgentsAdministrationClientBuilder.java | 538 +++++ .../persistent/RunStepsAsyncClient.java | 345 +++ .../ai/agents/persistent/RunStepsClient.java | 314 +++ .../ai/agents/persistent/RunsAsyncClient.java | 1125 +++++++++ .../ai/agents/persistent/RunsClient.java | 1089 +++++++++ .../agents/persistent/ThreadsAsyncClient.java | 748 ++++++ .../ai/agents/persistent/ThreadsClient.java | 712 ++++++ .../VectorStoreFileBatchesAsyncClient.java | 448 ++++ .../VectorStoreFileBatchesClient.java | 417 ++++ .../VectorStoreFilesAsyncClient.java | 429 ++++ .../persistent/VectorStoreFilesClient.java | 396 ++++ .../persistent/VectorStoresAsyncClient.java | 589 +++++ .../agents/persistent/VectorStoresClient.java | 552 +++++ .../persistent/implementation/FilesImpl.java | 519 ++++ .../implementation/MessagesImpl.java | 953 ++++++++ .../MultipartFormDataHelper.java | 209 ++ ...sistentAgentsAdministrationClientImpl.java | 2082 +++++++++++++++++ .../implementation/RunStepsImpl.java | 578 +++++ .../persistent/implementation/RunsImpl.java | 1884 +++++++++++++++ .../implementation/ThreadsImpl.java | 1310 +++++++++++ .../VectorStoreFileBatchesImpl.java | 723 ++++++ .../implementation/VectorStoreFilesImpl.java | 692 ++++++ .../implementation/VectorStoresImpl.java | 928 ++++++++ .../models/CreateAgentRequest.java | 418 ++++ .../models/CreateMessageRequest.java | 195 ++ .../models/CreateRunRequest.java | 651 ++++++ .../models/CreateThreadAndRunRequest.java | 650 +++++ .../models/CreateThreadRequest.java | 176 ++ .../CreateVectorStoreFileBatchRequest.java | 162 ++ .../models/CreateVectorStoreFileRequest.java | 157 ++ .../models/CreateVectorStoreRequest.java | 266 +++ .../implementation/models/FileDetails.java | 137 ++ .../models/ModifyVectorStoreRequest.java | 161 ++ .../models/SubmitToolOutputsToRunRequest.java | 121 + .../models/UpdateAgentRequest.java | 412 ++++ .../models/UpdateMessageRequest.java | 98 + .../models/UpdateRunRequest.java | 98 + .../models/UpdateThreadRequest.java | 141 ++ .../models/UploadFileRequest.java | 89 + .../implementation/models/package-info.java | 9 + .../implementation/package-info.java | 9 + .../models/AISearchIndexResource.java | 238 ++ .../models/AgentDeletionStatus.java | 121 + .../models/AzureAISearchQueryType.java | 75 + .../models/AzureAISearchResource.java | 96 + .../models/AzureAISearchToolDefinition.java | 78 + .../models/AzureFunctionBinding.java | 99 + .../models/AzureFunctionDefinition.java | 129 + .../models/AzureFunctionStorageQueue.java | 105 + .../models/AzureFunctionToolDefinition.java | 105 + .../models/BingCustomSearchConfiguration.java | 241 ++ .../BingCustomSearchConfigurationList.java | 87 + .../BingCustomSearchToolDefinition.java | 105 + .../BingGroundingSearchConfiguration.java | 219 ++ .../BingGroundingSearchConfigurationList.java | 89 + .../models/BingGroundingToolDefinition.java | 105 + .../models/CodeInterpreterToolDefinition.java | 79 + .../models/CodeInterpreterToolResource.java | 132 ++ .../models/ConnectedAgentDetails.java | 127 + .../models/ConnectedAgentToolDefinition.java | 105 + .../persistent/models/CreateAgentOptions.java | 324 +++ .../persistent/models/CreateRunOptions.java | 573 +++++ .../models/CreateThreadAndRunOptions.java | 519 ++++ .../agents/persistent/models/DoneEvent.java | 51 + .../agents/persistent/models/ErrorEvent.java | 51 + .../persistent/models/FileDeletionStatus.java | 121 + .../ai/agents/persistent/models/FileInfo.java | 239 ++ .../persistent/models/FileListResponse.java | 100 + .../agents/persistent/models/FilePurpose.java | 87 + .../models/FileSearchRankingOptions.java | 104 + .../models/FileSearchToolCallContent.java | 99 + .../models/FileSearchToolDefinition.java | 109 + .../FileSearchToolDefinitionDetails.java | 135 ++ .../models/FileSearchToolResource.java | 137 ++ .../agents/persistent/models/FileState.java | 95 + .../persistent/models/FunctionDefinition.java | 143 ++ .../persistent/models/FunctionName.java | 82 + .../models/FunctionToolDefinition.java | 104 + .../persistent/models/ImageDetailLevel.java | 63 + .../models/IncompleteDetailsReason.java | 58 + .../models/IncompleteRunDetails.java | 83 + .../persistent/models/ListSortOrder.java | 57 + .../persistent/models/MessageAttachment.java | 153 ++ .../persistent/models/MessageBlockType.java | 64 + .../persistent/models/MessageContent.java | 107 + .../persistent/models/MessageDelta.java | 105 + .../persistent/models/MessageDeltaChunk.java | 121 + .../models/MessageDeltaContent.java | 133 ++ .../models/MessageDeltaImageFileContent.java | 110 + .../MessageDeltaImageFileContentObject.java | 79 + .../models/MessageDeltaTextAnnotation.java | 135 ++ .../models/MessageDeltaTextContent.java | 109 + .../models/MessageDeltaTextContentObject.java | 101 + ...essageDeltaTextFileCitationAnnotation.java | 173 ++ ...DeltaTextFileCitationAnnotationObject.java | 99 + .../MessageDeltaTextFilePathAnnotation.java | 173 ++ ...sageDeltaTextFilePathAnnotationObject.java | 80 + ...MessageDeltaTextUrlCitationAnnotation.java | 154 ++ .../MessageDeltaTextUrlCitationDetails.java | 105 + .../models/MessageImageFileContent.java | 104 + .../models/MessageImageFileDetails.java | 82 + .../models/MessageImageFileParam.java | 116 + .../models/MessageImageUrlParam.java | 118 + .../models/MessageIncompleteDetails.java | 82 + .../MessageIncompleteDetailsReason.java | 75 + .../models/MessageInputContentBlock.java | 110 + .../models/MessageInputImageFileBlock.java | 106 + .../models/MessageInputImageUrlBlock.java | 104 + .../models/MessageInputTextBlock.java | 104 + .../agents/persistent/models/MessageRole.java | 57 + .../persistent/models/MessageStatus.java | 63 + .../persistent/models/MessageStreamEvent.java | 75 + .../models/MessageTextAnnotation.java | 135 ++ .../persistent/models/MessageTextContent.java | 104 + .../persistent/models/MessageTextDetails.java | 105 + .../MessageTextFileCitationAnnotation.java | 157 ++ .../MessageTextFileCitationDetails.java | 104 + .../models/MessageTextFilePathAnnotation.java | 154 ++ .../models/MessageTextFilePathDetails.java | 82 + .../MessageTextUrlCitationAnnotation.java | 154 ++ .../models/MessageTextUrlCitationDetails.java | 105 + .../models/MicrosoftFabricToolDefinition.java | 105 + .../models/OpenApiAnonymousAuthDetails.java | 78 + .../persistent/models/OpenApiAuthDetails.java | 109 + .../persistent/models/OpenApiAuthType.java | 66 + .../models/OpenApiConnectionAuthDetails.java | 105 + .../OpenApiConnectionSecurityScheme.java | 82 + .../models/OpenApiFunctionDefinition.java | 200 ++ .../models/OpenApiManagedAuthDetails.java | 105 + .../models/OpenApiManagedSecurityScheme.java | 82 + .../models/OpenApiToolDefinition.java | 104 + .../persistent/models/PersistentAgent.java | 377 +++ .../models/PersistentAgentStreamEvent.java | 213 ++ .../models/PersistentAgentThread.java | 186 ++ .../PersistentAgentThreadCreationOptions.java | 176 ++ .../PersistentAgentsNamedToolChoice.java | 117 + .../PersistentAgentsNamedToolChoiceType.java | 100 + .../PersistentAgentsResponseFormat.java | 93 + .../PersistentAgentsResponseFormatMode.java | 57 + .../PersistentAgentsToolChoiceOptionMode.java | 58 + .../persistent/models/RequiredAction.java | 105 + .../models/RequiredFunctionToolCall.java | 111 + .../RequiredFunctionToolCallDetails.java | 107 + .../persistent/models/RequiredToolCall.java | 131 ++ .../persistent/models/ResponseFormat.java | 57 + .../models/ResponseFormatJsonSchema.java | 142 ++ .../models/ResponseFormatJsonSchemaType.java | 99 + .../models/RunAdditionalFieldList.java | 52 + .../persistent/models/RunCompletionUsage.java | 127 + .../ai/agents/persistent/models/RunError.java | 104 + .../agents/persistent/models/RunStatus.java | 93 + .../ai/agents/persistent/models/RunStep.java | 466 ++++ .../models/RunStepAzureAISearchToolCall.java | 114 + .../RunStepBingCustomSearchToolCall.java | 114 + .../models/RunStepBingGroundingToolCall.java | 114 + .../RunStepCodeInterpreterImageOutput.java | 105 + .../RunStepCodeInterpreterImageReference.java | 83 + .../RunStepCodeInterpreterLogOutput.java | 105 + .../RunStepCodeInterpreterToolCall.java | 112 + ...RunStepCodeInterpreterToolCallDetails.java | 107 + .../RunStepCodeInterpreterToolCallOutput.java | 108 + .../models/RunStepCompletionUsage.java | 126 + .../persistent/models/RunStepDelta.java | 78 + .../persistent/models/RunStepDeltaChunk.java | 121 + ...pDeltaCodeInterpreterDetailItemObject.java | 107 + ...unStepDeltaCodeInterpreterImageOutput.java | 111 + ...DeltaCodeInterpreterImageOutputObject.java | 80 + .../RunStepDeltaCodeInterpreterLogOutput.java | 111 + .../RunStepDeltaCodeInterpreterOutput.java | 135 ++ .../RunStepDeltaCodeInterpreterToolCall.java | 115 + .../persistent/models/RunStepDeltaDetail.java | 107 + .../RunStepDeltaFileSearchToolCall.java | 115 + .../models/RunStepDeltaFunction.java | 116 + .../models/RunStepDeltaFunctionToolCall.java | 115 + .../models/RunStepDeltaMessageCreation.java | 98 + .../RunStepDeltaMessageCreationObject.java | 79 + .../models/RunStepDeltaToolCall.java | 157 ++ .../models/RunStepDeltaToolCallObject.java | 100 + .../persistent/models/RunStepDetails.java | 107 + .../persistent/models/RunStepError.java | 104 + .../persistent/models/RunStepErrorCode.java | 57 + .../models/RunStepFileSearchToolCall.java | 112 + .../RunStepFileSearchToolCallResult.java | 152 ++ .../RunStepFileSearchToolCallResults.java | 106 + .../models/RunStepFunctionToolCall.java | 112 + .../RunStepFunctionToolCallDetails.java | 104 + .../models/RunStepMessageCreationDetails.java | 105 + .../RunStepMessageCreationReference.java | 82 + .../RunStepMicrosoftFabricToolCall.java | 114 + .../models/RunStepOpenApiToolCall.java | 112 + .../models/RunStepSharepointToolCall.java | 114 + .../persistent/models/RunStepStatus.java | 75 + .../persistent/models/RunStepStreamEvent.java | 87 + .../persistent/models/RunStepToolCall.java | 147 ++ .../models/RunStepToolCallDetails.java | 105 + .../agents/persistent/models/RunStepType.java | 57 + .../persistent/models/RunStreamEvent.java | 105 + .../models/SharepointToolDefinition.java | 105 + .../models/SubmitToolOutputsAction.java | 105 + .../models/SubmitToolOutputsDetails.java | 83 + .../models/ThreadDeletionStatus.java | 121 + .../persistent/models/ThreadMessage.java | 402 ++++ .../models/ThreadMessageOptions.java | 194 ++ .../agents/persistent/models/ThreadRun.java | 753 ++++++ .../persistent/models/ThreadStreamEvent.java | 51 + .../persistent/models/ToolConnection.java | 82 + .../persistent/models/ToolConnectionList.java | 96 + .../persistent/models/ToolDefinition.java | 125 + .../agents/persistent/models/ToolOutput.java | 123 + .../persistent/models/ToolResources.java | 156 ++ .../persistent/models/TruncationObject.java | 126 + .../persistent/models/TruncationStrategy.java | 57 + .../persistent/models/UpdateAgentOptions.java | 355 +++ ...ateCodeInterpreterToolResourceOptions.java | 94 + .../UpdateFileSearchToolResourceOptions.java | 95 + .../models/UpdateToolResourcesOptions.java | 167 ++ .../agents/persistent/models/VectorStore.java | 327 +++ ...ectorStoreAutoChunkingStrategyRequest.java | 80 + ...ctorStoreAutoChunkingStrategyResponse.java | 81 + .../VectorStoreChunkingStrategyRequest.java | 110 + ...ectorStoreChunkingStrategyRequestType.java | 58 + .../VectorStoreChunkingStrategyResponse.java | 110 + ...ctorStoreChunkingStrategyResponseType.java | 58 + .../models/VectorStoreConfiguration.java | 84 + .../models/VectorStoreConfigurations.java | 104 + .../models/VectorStoreDataSource.java | 105 + .../VectorStoreDataSourceAssetType.java | 58 + .../models/VectorStoreDeletionStatus.java | 121 + .../models/VectorStoreExpirationPolicy.java | 105 + .../VectorStoreExpirationPolicyAnchor.java | 51 + .../persistent/models/VectorStoreFile.java | 246 ++ .../models/VectorStoreFileBatch.java | 197 ++ .../models/VectorStoreFileBatchStatus.java | 69 + .../models/VectorStoreFileCount.java | 170 ++ .../models/VectorStoreFileDeletionStatus.java | 121 + .../models/VectorStoreFileError.java | 104 + .../models/VectorStoreFileErrorCode.java | 63 + .../models/VectorStoreFileStatus.java | 69 + .../models/VectorStoreFileStatusFilter.java | 69 + ...torStoreStaticChunkingStrategyOptions.java | 109 + ...torStoreStaticChunkingStrategyRequest.java | 105 + ...orStoreStaticChunkingStrategyResponse.java | 105 + .../persistent/models/VectorStoreStatus.java | 63 + .../persistent/models/package-info.java | 9 + .../PersistentAgentServerSentEvents.java | 201 ++ .../streaming/StreamMessageCreation.java | 37 + .../models/streaming/StreamMessageUpdate.java | 36 + .../streaming/StreamRequiredAction.java | 37 + .../models/streaming/StreamRunCreation.java | 36 + .../models/streaming/StreamRunStepUpdate.java | 37 + .../streaming/StreamThreadCreation.java | 36 + .../streaming/StreamThreadRunCreation.java | 37 + .../models/streaming/StreamTypeFactory.java | 96 + .../models/streaming/StreamUpdate.java | 35 + .../models/streaming/package-info.java | 8 + .../ai/agents/persistent/package-info.java | 9 + .../src/main/java/module-info.java | 15 + ...-agents-persistent_apiview_properties.json | 390 +++ .../azure-ai-agents-persistent.properties | 2 + .../AgentAdditionalMessageAsyncSample.java | 106 + .../AgentAdditionalMessageSample.java | 68 + .../AgentAzureAISearchAsyncSample.java | 107 + .../persistent/AgentAzureAISearchSample.java | 71 + .../AgentAzureFunctionAsyncSample.java | 147 ++ .../persistent/AgentAzureFunctionSample.java | 109 + .../persistent/AgentBasicAsyncSample.java | 79 + .../agents/persistent/AgentBasicSample.java | 61 + .../AgentBingCustomSearchAsyncSample.java | 120 + .../AgentBingCustomSearchSample.java | 82 + .../AgentBingGroundingAsyncSample.java | 93 + .../persistent/AgentBingGroundingSample.java | 73 + ...preterEnterpriseFileSearchAsyncSample.java | 94 + ...InterpreterEnterpriseFileSearchSample.java | 77 + ...eInterpreterFileAttachmentAsyncSample.java | 142 ++ ...ntCodeInterpreterFileAttachmentSample.java | 88 + .../AgentConnectedAgentAsyncSample.java | 129 + .../persistent/AgentConnectedAgentSample.java | 76 + .../AgentEnterpriseFileSearchAsyncSample.java | 128 + .../AgentEnterpriseFileSearchSample.java | 81 + .../AgentFabricToolAsyncSample.java | 115 + .../persistent/AgentFabricToolSample.java | 71 + .../AgentFileSearchAsyncSample.java | 138 ++ .../persistent/AgentFileSearchSample.java | 93 + .../persistent/AgentFunctionsAsyncSample.java | 198 ++ .../persistent/AgentFunctionsSample.java | 160 ++ .../AgentFunctionsStreamingAsyncSample.java | 255 ++ .../AgentFunctionsStreamingSample.java | 231 ++ .../AgentImageInputBase64AsyncSample.java | 118 + .../AgentImageInputBase64Sample.java | 88 + .../AgentImageInputFileAsyncSample.java | 119 + .../persistent/AgentImageInputFileSample.java | 97 + .../AgentImageInputUrlAsyncSample.java | 87 + .../persistent/AgentImageInputUrlSample.java | 83 + .../AgentListThreadAsyncSample.java | 25 + .../persistent/AgentListThreadSample.java | 22 + .../persistent/AgentOpenApiAsyncSample.java | 108 + .../agents/persistent/AgentOpenApiSample.java | 90 + .../AgentSharepointToolAsyncSample.java | 91 + .../persistent/AgentSharepointToolSample.java | 70 + .../persistent/AgentStreamingAsyncSample.java | 92 + .../persistent/AgentStreamingSample.java | 71 + ...eBatchEnterpriseFileSearchAsyncSample.java | 110 + ...rStoreBatchEnterpriseFileSearchSample.java | 84 + ...VectorStoreBatchFileSearchAsyncSample.java | 131 ++ ...AgentVectorStoreBatchFileSearchSample.java | 104 + .../ai/agents/persistent/ReadmeSamples.java | 12 + .../ai/agents/persistent/SampleUtils.java | 162 ++ .../src/samples/resources/product_info.md | 51 + .../src/samples/resources/sample.html | 12 + .../src/samples/resources/sample_image.jpg | Bin 0 -> 3347 bytes .../samples/resources/weather_openapi.json | 62 + .../AdministrationAsyncClientTest.java | 109 + .../persistent/AdministrationClientTest.java | 100 + .../ai/agents/persistent/ClientTestBase.java | 120 + .../persistent/FilesAsyncClientTest.java | 126 + .../ai/agents/persistent/FilesClientTest.java | 114 + .../persistent/MessagesAsyncClientTest.java | 191 ++ .../agents/persistent/MessagesClientTest.java | 139 ++ .../persistent/RunStepsAsyncClientTest.java | 131 ++ .../agents/persistent/RunStepsClientTest.java | 105 + .../persistent/RunsAsyncClientTest.java | 196 ++ .../ai/agents/persistent/RunsClientTest.java | 154 ++ .../azure/ai/agents/persistent/TestUtils.java | 55 + .../persistent/ThreadsAsyncClientTest.java | 138 ++ .../agents/persistent/ThreadsClientTest.java | 107 + ...VectorStoreFileBatchesAsyncClientTest.java | 182 ++ .../VectorStoreFileBatchesClientTest.java | 149 ++ .../VectorStoreFilesAsyncClientTest.java | 178 ++ .../VectorStoreFilesClientTest.java | 163 ++ .../VectorStoresAsyncClientTest.java | 140 ++ .../persistent/VectorStoresClientTest.java | 129 + .../tsp-location.yaml | 5 + sdk/ai/ci.yml | 8 + sdk/ai/pom.xml | 1 + 346 files changed, 59481 insertions(+) create mode 100644 sdk/ai/azure-ai-agents-persistent/CHANGELOG.md create mode 100644 sdk/ai/azure-ai-agents-persistent/README.md create mode 100644 sdk/ai/azure-ai-agents-persistent/assets.json create mode 100644 sdk/ai/azure-ai-agents-persistent/pom.xml create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/AgentsServiceVersion.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/FilesAsyncClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/FilesClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/MessagesAsyncClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/MessagesClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationAsyncClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClientBuilder.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunStepsAsyncClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunStepsClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/ThreadsAsyncClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/ThreadsClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesAsyncClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFilesAsyncClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFilesClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoresAsyncClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoresClient.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/FilesImpl.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/MessagesImpl.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/MultipartFormDataHelper.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/PersistentAgentsAdministrationClientImpl.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/RunStepsImpl.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/RunsImpl.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/ThreadsImpl.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoreFileBatchesImpl.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoreFilesImpl.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoresImpl.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateAgentRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateMessageRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateRunRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateThreadAndRunRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateThreadRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreFileBatchRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreFileRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/FileDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/ModifyVectorStoreRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/SubmitToolOutputsToRunRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateAgentRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateMessageRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateRunRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateThreadRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UploadFileRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/package-info.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/package-info.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AISearchIndexResource.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AgentDeletionStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchQueryType.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchResource.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionBinding.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionStorageQueue.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfiguration.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfigurationList.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingSearchConfiguration.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingSearchConfigurationList.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CodeInterpreterToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CodeInterpreterToolResource.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ConnectedAgentDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ConnectedAgentToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateAgentOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateRunOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateThreadAndRunOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/DoneEvent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ErrorEvent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileDeletionStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileInfo.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileListResponse.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FilePurpose.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchRankingOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolCallContent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolDefinitionDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolResource.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileState.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionName.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ImageDetailLevel.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/IncompleteDetailsReason.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/IncompleteRunDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ListSortOrder.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageAttachment.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageBlockType.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageContent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDelta.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaChunk.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaContent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaImageFileContent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaImageFileContentObject.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextAnnotation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextContent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextContentObject.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFileCitationAnnotation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFileCitationAnnotationObject.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFilePathAnnotation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFilePathAnnotationObject.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextUrlCitationAnnotation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextUrlCitationDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileContent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileParam.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageUrlParam.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageIncompleteDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageIncompleteDetailsReason.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputContentBlock.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputImageFileBlock.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputImageUrlBlock.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputTextBlock.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageRole.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageStreamEvent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextAnnotation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextContent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFileCitationAnnotation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFileCitationDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFilePathAnnotation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFilePathDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextUrlCitationAnnotation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextUrlCitationDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MicrosoftFabricToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAnonymousAuthDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAuthDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAuthType.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiConnectionAuthDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiConnectionSecurityScheme.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiFunctionDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiManagedAuthDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiManagedSecurityScheme.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentStreamEvent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentThread.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentThreadCreationOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoice.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoiceType.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormat.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormatMode.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsToolChoiceOptionMode.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredAction.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredFunctionToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredFunctionToolCallDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormat.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormatJsonSchema.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormatJsonSchemaType.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunAdditionalFieldList.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunCompletionUsage.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunError.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStep.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepAzureAISearchToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingCustomSearchToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingGroundingToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterImageOutput.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterImageReference.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterLogOutput.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCallDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCallOutput.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCompletionUsage.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDelta.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaChunk.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterDetailItemObject.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterImageOutput.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterImageOutputObject.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterLogOutput.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterOutput.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaDetail.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFileSearchToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFunction.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFunctionToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaMessageCreation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaMessageCreationObject.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaToolCallObject.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepError.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepErrorCode.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCallResult.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCallResults.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFunctionToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFunctionToolCallDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMessageCreationDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMessageCreationReference.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMicrosoftFabricToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepOpenApiToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepSharepointToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepStreamEvent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCall.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCallDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepType.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStreamEvent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SharepointToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SubmitToolOutputsAction.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SubmitToolOutputsDetails.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadDeletionStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadMessage.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadMessageOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadRun.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadStreamEvent.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnection.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnectionList.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolDefinition.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolOutput.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolResources.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/TruncationObject.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/TruncationStrategy.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateAgentOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateCodeInterpreterToolResourceOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateFileSearchToolResourceOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateToolResourcesOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStore.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreAutoChunkingStrategyRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreAutoChunkingStrategyResponse.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyRequestType.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyResponse.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyResponseType.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreConfiguration.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreConfigurations.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDataSource.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDataSourceAssetType.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDeletionStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreExpirationPolicy.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreExpirationPolicyAnchor.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFile.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileBatch.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileBatchStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileCount.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileDeletionStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileError.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileErrorCode.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileStatusFilter.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyOptions.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyRequest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyResponse.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStatus.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/package-info.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/PersistentAgentServerSentEvents.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageCreation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageUpdate.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRequiredAction.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunCreation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunStepUpdate.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadCreation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadRunCreation.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamTypeFactory.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamUpdate.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/package-info.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/package-info.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/module-info.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/resources/META-INF/azure-ai-agents-persistent_apiview_properties.json create mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/resources/azure-ai-agents-persistent.properties create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAdditionalMessageAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAdditionalMessageSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureAISearchAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureAISearchSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureFunctionAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureFunctionSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBasicAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBasicSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterEnterpriseFileSearchAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterEnterpriseFileSearchSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterFileAttachmentAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterFileAttachmentSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentConnectedAgentAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentConnectedAgentSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentEnterpriseFileSearchAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentEnterpriseFileSearchSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFileSearchAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFileSearchSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputBase64AsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputBase64Sample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputFileAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputFileSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputUrlAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputUrlSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentListThreadAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentListThreadSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentOpenApiAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentOpenApiSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchEnterpriseFileSearchAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchEnterpriseFileSearchSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchFileSearchAsyncSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchFileSearchSample.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/ReadmeSamples.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/resources/product_info.md create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/resources/sample.html create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/resources/sample_image.jpg create mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/resources/weather_openapi.json create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/AdministrationAsyncClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/AdministrationClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/FilesAsyncClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/FilesClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesAsyncClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunStepsAsyncClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunStepsClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsAsyncClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/TestUtils.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ThreadsAsyncClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ThreadsClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesAsyncClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFilesAsyncClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFilesClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoresAsyncClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoresClientTest.java create mode 100644 sdk/ai/azure-ai-agents-persistent/tsp-location.yaml diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 4a90a182f7a0..4d1b1a4b2b0b 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -35,6 +35,7 @@ com.azure:azure-sdk-parent;1.6.0;1.6.0 com.azure:azure-client-sdk-parent;1.7.0;1.7.0 +com.azure:azure-ai-agents-persistent;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-ai-anomalydetector;3.0.0-beta.5;3.0.0-beta.6 com.azure:azure-ai-contentsafety;1.0.11;1.1.0-beta.1 com.azure:azure-ai-documentintelligence;1.0.1;1.1.0-beta.1 diff --git a/sdk/ai/azure-ai-agents-persistent/CHANGELOG.md b/sdk/ai/azure-ai-agents-persistent/CHANGELOG.md new file mode 100644 index 000000000000..0a8d5a9bb4f1 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/CHANGELOG.md @@ -0,0 +1,13 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +- Azure Agents client library for Java. This package contains Microsoft Azure Agents client library. + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/ai/azure-ai-agents-persistent/README.md b/sdk/ai/azure-ai-agents-persistent/README.md new file mode 100644 index 000000000000..8269183671c2 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/README.md @@ -0,0 +1,78 @@ +# Azure Agents client library for Java + +Azure Agents client library for Java. + +This package contains Microsoft Azure Agents client library. + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] +- [Product documentation][product_documentation] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure:azure-ai-agents-persistent;current}) +```xml + + com.azure + azure-ai-agents-persistent + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Authentication + +[Azure Identity][azure_identity] package provides the default implementation for authenticating the client. + +## Key concepts + +## Examples + +```java com.azure.ai.agents.persistent.readme +``` + +### Service API versions + +The client library targets the latest service API version by default. +The service client builder accepts an optional service API version parameter to specify which API version to communicate. + +#### Select a service API version + +You have the flexibility to explicitly select a supported service API version when initializing a service client via the service client builder. +This ensures that the client can communicate with services using the specified API version. + +When selecting an API version, it is important to verify that there are no breaking changes compared to the latest API version. +If there are significant differences, API calls may fail due to incompatibility. + +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[product_documentation]: https://azure.microsoft.com/services/ +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity diff --git a/sdk/ai/azure-ai-agents-persistent/assets.json b/sdk/ai/azure-ai-agents-persistent/assets.json new file mode 100644 index 000000000000..82faa1dc490e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/assets.json @@ -0,0 +1 @@ +{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/ai/azure-ai-agents-persistent","Tag":""} \ No newline at end of file diff --git a/sdk/ai/azure-ai-agents-persistent/pom.xml b/sdk/ai/azure-ai-agents-persistent/pom.xml new file mode 100644 index 000000000000..d0fa64ed23b8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure + azure-ai-agents-persistent + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Agents + This package contains Microsoft Azure Agents client library. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 0.20 + 0.10 + + + --add-exports com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED + --add-opens com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED + + + + + com.azure + azure-core + 1.55.3 + + + com.azure + azure-core-http-netty + 1.15.11 + + + com.azure + azure-core-test + 1.27.0-beta.8 + test + + + com.azure + azure-identity + 1.16.0 + test + + + diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/AgentsServiceVersion.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/AgentsServiceVersion.java new file mode 100644 index 000000000000..8ef625ace3e0 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/AgentsServiceVersion.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent; + +import com.azure.core.util.ServiceVersion; + +/** + * Service version of AgentsClient. + */ +public enum AgentsServiceVersion implements ServiceVersion { + /** + * Enum value 2025-05-01. + */ + V2025_05_01("2025-05-01"), + + /** + * Enum value 2025-05-15-preview. + */ + V2025_05_15_PREVIEW("2025-05-15-preview"), + + /** + * Enum value v1. + */ + V1("v1"); + + private final String version; + + AgentsServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link AgentsServiceVersion}. + */ + public static AgentsServiceVersion getLatest() { + return V1; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/FilesAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/FilesAsyncClient.java new file mode 100644 index 000000000000..ff5198f10acb --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/FilesAsyncClient.java @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.FilesImpl; +import com.azure.ai.agents.persistent.implementation.MultipartFormDataHelper; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.FileDeletionStatus; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FileListResponse; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.Objects; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class, isAsync = true) +public final class FilesAsyncClient { + + @Generated + private final FilesImpl serviceClient; + + /** + * Initializes an instance of FilesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FilesAsyncClient(FilesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Gets a list of previously uploaded files. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
purposeStringNoThe purpose of the file. Allowed values: "fine-tune", + * "fine-tune-results", "assistants", "assistants_output", "batch", "batch_output", "vision".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     data (Required): [
+     *          (Required){
+     *             object: String (Required)
+     *             id: String (Required)
+     *             bytes: int (Required)
+     *             filename: String (Required)
+     *             created_at: long (Required)
+     *             purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *             status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *             status_details: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of previously uploaded files along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listFilesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.listFilesWithResponseAsync(requestOptions); + } + + /** + * Uploads a file for use by other operations. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     id: String (Required)
+     *     bytes: int (Required)
+     *     filename: String (Required)
+     *     created_at: long (Required)
+     *     purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *     status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *     status_details: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body Multipart body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> uploadFileWithResponse(BinaryData body, RequestOptions requestOptions) { + // Operation 'uploadFile' is of content-type 'multipart/form-data'. Protocol API is not usable and hence not + // generated. + return this.serviceClient.uploadFileWithResponseAsync(body, requestOptions); + } + + /** + * Delete a previously uploaded file. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param fileId The ID of the file to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a status response from a file deletion operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteFileWithResponse(String fileId, RequestOptions requestOptions) { + return this.serviceClient.deleteFileWithResponseAsync(fileId, requestOptions); + } + + /** + * Returns information about a specific file. Does not retrieve file content. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     id: String (Required)
+     *     bytes: int (Required)
+     *     filename: String (Required)
+     *     created_at: long (Required)
+     *     purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *     status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *     status_details: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param fileId The ID of the file to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFileWithResponse(String fileId, RequestOptions requestOptions) { + return this.serviceClient.getFileWithResponseAsync(fileId, requestOptions); + } + + /** + * Retrieves the raw content of a specific file. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param fileId The ID of the file to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFileContentWithResponse(String fileId, RequestOptions requestOptions) { + return this.serviceClient.getFileContentWithResponseAsync(fileId, requestOptions); + } + + /** + * Gets a list of previously uploaded files. + * + * @param purpose The purpose of the file. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of previously uploaded files on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listFiles(FilePurpose purpose) { + // Generated convenience method for listFilesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (purpose != null) { + requestOptions.addQueryParam("purpose", purpose.toString(), false); + } + return listFilesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FileListResponse.class)); + } + + /** + * Gets a list of previously uploaded files. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of previously uploaded files on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listFiles() { + // Generated convenience method for listFilesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listFilesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FileListResponse.class)); + } + + /** + * Uploads a file for use by other operations. + * + * @param body Multipart body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an agent that can call the model and use tools on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono uploadFile(UploadFileRequest body) { + // Generated convenience method for uploadFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadFileWithResponse(new MultipartFormDataHelper(requestOptions) + .serializeFileField("file", body.getFile().getContent(), body.getFile().getContentType(), + body.getFile().getFilename()) + .serializeTextField("purpose", Objects.toString(body.getPurpose())) + .serializeTextField("filename", body.getFilename()) + .end() + .getRequestBody(), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FileInfo.class)); + } + + /** + * Delete a previously uploaded file. + * + * @param fileId The ID of the file to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a status response from a file deletion operation on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteFile(String fileId) { + // Generated convenience method for deleteFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteFileWithResponse(fileId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FileDeletionStatus.class)); + } + + /** + * Returns information about a specific file. Does not retrieve file content. + * + * @param fileId The ID of the file to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an agent that can call the model and use tools on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getFile(String fileId) { + // Generated convenience method for getFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFileWithResponse(fileId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(FileInfo.class)); + } + + /** + * Retrieves the raw content of a specific file. + * + * @param fileId The ID of the file to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getFileContent(String fileId) { + // Generated convenience method for getFileContentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFileContentWithResponse(fileId, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/FilesClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/FilesClient.java new file mode 100644 index 000000000000..062dfa4f6533 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/FilesClient.java @@ -0,0 +1,336 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.FilesImpl; +import com.azure.ai.agents.persistent.implementation.MultipartFormDataHelper; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.FileDeletionStatus; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FileListResponse; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import java.util.Objects; + +/** + * Initializes a new instance of the synchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class) +public final class FilesClient { + + @Generated + private final FilesImpl serviceClient; + + /** + * Initializes an instance of FilesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FilesClient(FilesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Gets a list of previously uploaded files. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
purposeStringNoThe purpose of the file. Allowed values: "fine-tune", + * "fine-tune-results", "assistants", "assistants_output", "batch", "batch_output", "vision".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     data (Required): [
+     *          (Required){
+     *             object: String (Required)
+     *             id: String (Required)
+     *             bytes: int (Required)
+     *             filename: String (Required)
+     *             created_at: long (Required)
+     *             purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *             status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *             status_details: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of previously uploaded files along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listFilesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.listFilesWithResponse(requestOptions); + } + + /** + * Uploads a file for use by other operations. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     id: String (Required)
+     *     bytes: int (Required)
+     *     filename: String (Required)
+     *     created_at: long (Required)
+     *     purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *     status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *     status_details: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body Multipart body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response uploadFileWithResponse(BinaryData body, RequestOptions requestOptions) { + // Operation 'uploadFile' is of content-type 'multipart/form-data'. Protocol API is not usable and hence not + // generated. + return this.serviceClient.uploadFileWithResponse(body, requestOptions); + } + + /** + * Delete a previously uploaded file. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param fileId The ID of the file to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a status response from a file deletion operation along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteFileWithResponse(String fileId, RequestOptions requestOptions) { + return this.serviceClient.deleteFileWithResponse(fileId, requestOptions); + } + + /** + * Returns information about a specific file. Does not retrieve file content. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     id: String (Required)
+     *     bytes: int (Required)
+     *     filename: String (Required)
+     *     created_at: long (Required)
+     *     purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *     status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *     status_details: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param fileId The ID of the file to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFileWithResponse(String fileId, RequestOptions requestOptions) { + return this.serviceClient.getFileWithResponse(fileId, requestOptions); + } + + /** + * Retrieves the raw content of a specific file. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param fileId The ID of the file to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFileContentWithResponse(String fileId, RequestOptions requestOptions) { + return this.serviceClient.getFileContentWithResponse(fileId, requestOptions); + } + + /** + * Gets a list of previously uploaded files. + * + * @param purpose The purpose of the file. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of previously uploaded files. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FileListResponse listFiles(FilePurpose purpose) { + // Generated convenience method for listFilesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (purpose != null) { + requestOptions.addQueryParam("purpose", purpose.toString(), false); + } + return listFilesWithResponse(requestOptions).getValue().toObject(FileListResponse.class); + } + + /** + * Gets a list of previously uploaded files. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of previously uploaded files. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FileListResponse listFiles() { + // Generated convenience method for listFilesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listFilesWithResponse(requestOptions).getValue().toObject(FileListResponse.class); + } + + /** + * Uploads a file for use by other operations. + * + * @param body Multipart body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an agent that can call the model and use tools. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + FileInfo uploadFile(UploadFileRequest body) { + // Generated convenience method for uploadFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadFileWithResponse(new MultipartFormDataHelper(requestOptions) + .serializeFileField("file", body.getFile().getContent(), body.getFile().getContentType(), + body.getFile().getFilename()) + .serializeTextField("purpose", Objects.toString(body.getPurpose())) + .serializeTextField("filename", body.getFilename()) + .end() + .getRequestBody(), requestOptions).getValue().toObject(FileInfo.class); + } + + /** + * Delete a previously uploaded file. + * + * @param fileId The ID of the file to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a status response from a file deletion operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FileDeletionStatus deleteFile(String fileId) { + // Generated convenience method for deleteFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteFileWithResponse(fileId, requestOptions).getValue().toObject(FileDeletionStatus.class); + } + + /** + * Returns information about a specific file. Does not retrieve file content. + * + * @param fileId The ID of the file to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an agent that can call the model and use tools. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public FileInfo getFile(String fileId) { + // Generated convenience method for getFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFileWithResponse(fileId, requestOptions).getValue().toObject(FileInfo.class); + } + + /** + * Retrieves the raw content of a specific file. + * + * @param fileId The ID of the file to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData getFileContent(String fileId) { + // Generated convenience method for getFileContentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFileContentWithResponse(fileId, requestOptions).getValue(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/MessagesAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/MessagesAsyncClient.java new file mode 100644 index 000000000000..46262e239ae8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/MessagesAsyncClient.java @@ -0,0 +1,643 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.MessagesImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateMessageRequest; +import com.azure.ai.agents.persistent.implementation.models.UpdateMessageRequest; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.MessageAttachment; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class, isAsync = true) +public final class MessagesAsyncClient { + + @Generated + private final MessagesImpl serviceClient; + + /** + * Initializes an instance of MessagesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MessagesAsyncClient(MessagesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a new message on a specified thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     role: String(user/assistant) (Required)
+     *     content: BinaryData (Required)
+     *     attachments (Optional): [
+     *          (Optional){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param createMessageRequest The createMessageRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createMessageWithResponse(String threadId, BinaryData createMessageRequest, + RequestOptions requestOptions) { + return this.serviceClient.createMessageWithResponseAsync(threadId, createMessageRequest, requestOptions); + } + + /** + * Retrieves an existing message. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMessageWithResponse(String threadId, String messageId, + RequestOptions requestOptions) { + return this.serviceClient.getMessageWithResponseAsync(threadId, messageId, requestOptions); + } + + /** + * Modifies an existing message on an existing thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @param updateMessageRequest The updateMessageRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateMessageWithResponse(String threadId, String messageId, + BinaryData updateMessageRequest, RequestOptions requestOptions) { + return this.serviceClient.updateMessageWithResponseAsync(threadId, messageId, updateMessageRequest, + requestOptions); + } + + /** + * Creates a new message on a specified thread. + * + * @param threadId Identifier of the thread. + * @param role The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + * @param content The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + * @param attachments A list of files attached to the message, and the tools they should be added to. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createMessage(String threadId, MessageRole role, BinaryData content, + List attachments, Map metadata) { + // Generated convenience method for createMessageWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateMessageRequest createMessageRequestObj + = new CreateMessageRequest(role, content).setAttachments(attachments).setMetadata(metadata); + BinaryData createMessageRequest = BinaryData.fromObject(createMessageRequestObj); + return createMessageWithResponse(threadId, createMessageRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadMessage.class)); + } + + /** + * Creates a new message on a specified thread. + * + * @param threadId Identifier of the thread. + * @param role The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + * @param content The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createMessage(String threadId, MessageRole role, BinaryData content) { + // Generated convenience method for createMessageWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateMessageRequest createMessageRequestObj = new CreateMessageRequest(role, content); + BinaryData createMessageRequest = BinaryData.fromObject(createMessageRequestObj); + return createMessageWithResponse(threadId, createMessageRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadMessage.class)); + } + + /** + * Gets a list of messages that exist on a thread. + * + * @param threadId Identifier of the thread. + * @param runId Filter messages by the run ID that generated them. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of messages that exist on a thread as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listMessages(String threadId, String runId, Integer limit, ListSortOrder order, + String after, String before) { + // Generated convenience method for listMessages + RequestOptions requestOptions = new RequestOptions(); + if (runId != null) { + requestOptions.addQueryParam("run_id", runId, false); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + PagedFlux pagedFluxResponse = listMessages(threadId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ThreadMessage.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Gets a list of messages that exist on a thread. + * + * @param threadId Identifier of the thread. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of messages that exist on a thread as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listMessages(String threadId) { + // Generated convenience method for listMessages + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listMessages(threadId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ThreadMessage.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Retrieves an existing message. + * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getMessage(String threadId, String messageId) { + // Generated convenience method for getMessageWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMessageWithResponse(threadId, messageId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadMessage.class)); + } + + /** + * Modifies an existing message on an existing thread. + * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateMessage(String threadId, String messageId, Map metadata) { + // Generated convenience method for updateMessageWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateMessageRequest updateMessageRequestObj = new UpdateMessageRequest().setMetadata(metadata); + BinaryData updateMessageRequest = BinaryData.fromObject(updateMessageRequestObj); + return updateMessageWithResponse(threadId, messageId, updateMessageRequest, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadMessage.class)); + } + + /** + * Modifies an existing message on an existing thread. + * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateMessage(String threadId, String messageId) { + // Generated convenience method for updateMessageWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateMessageRequest updateMessageRequestObj = new UpdateMessageRequest(); + BinaryData updateMessageRequest = BinaryData.fromObject(updateMessageRequestObj); + return updateMessageWithResponse(threadId, messageId, updateMessageRequest, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadMessage.class)); + } + + /** + * Gets a list of messages that exist on a thread. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
run_idStringNoFilter messages by the run ID that generated them.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of messages that exist on a thread as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listMessages(String threadId, RequestOptions requestOptions) { + return this.serviceClient.listMessagesAsync(threadId, requestOptions); + } + + /** + * Creates a new message on a specified thread. + * + * @param threadId Identifier of the thread. + * @param role The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + * @param content The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createMessage(String threadId, MessageRole role, String content) { + BinaryData binaryContent = BinaryData.fromString(content); + return createMessage(threadId, role, binaryContent); + } + + /** + * Creates a new message on a specified thread. + * + * @param threadId Identifier of the thread. + * @param role The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + * @param content The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + * @param attachments A list of files attached to the message, and the tools they should be added to. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createMessage(String threadId, MessageRole role, String content, + List attachments, Map metadata) { + // Generated convenience method for createMessageWithResponse + BinaryData binaryContent = BinaryData.fromString(content); + return createMessage(threadId, role, binaryContent, attachments, metadata); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/MessagesClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/MessagesClient.java new file mode 100644 index 000000000000..94e4512de69e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/MessagesClient.java @@ -0,0 +1,609 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.MessagesImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateMessageRequest; +import com.azure.ai.agents.persistent.implementation.models.UpdateMessageRequest; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.MessageAttachment; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import java.util.List; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class) +public final class MessagesClient { + + @Generated + private final MessagesImpl serviceClient; + + /** + * Initializes an instance of MessagesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + MessagesClient(MessagesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a new message on a specified thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     role: String(user/assistant) (Required)
+     *     content: BinaryData (Required)
+     *     attachments (Optional): [
+     *          (Optional){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param createMessageRequest The createMessageRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createMessageWithResponse(String threadId, BinaryData createMessageRequest, + RequestOptions requestOptions) { + return this.serviceClient.createMessageWithResponse(threadId, createMessageRequest, requestOptions); + } + + /** + * Retrieves an existing message. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getMessageWithResponse(String threadId, String messageId, + RequestOptions requestOptions) { + return this.serviceClient.getMessageWithResponse(threadId, messageId, requestOptions); + } + + /** + * Modifies an existing message on an existing thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @param updateMessageRequest The updateMessageRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateMessageWithResponse(String threadId, String messageId, + BinaryData updateMessageRequest, RequestOptions requestOptions) { + return this.serviceClient.updateMessageWithResponse(threadId, messageId, updateMessageRequest, requestOptions); + } + + /** + * Creates a new message on a specified thread. + * + * @param threadId Identifier of the thread. + * @param role The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + * @param content The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + * @param attachments A list of files attached to the message, and the tools they should be added to. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadMessage createMessage(String threadId, MessageRole role, BinaryData content, + List attachments, Map metadata) { + // Generated convenience method for createMessageWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateMessageRequest createMessageRequestObj + = new CreateMessageRequest(role, content).setAttachments(attachments).setMetadata(metadata); + BinaryData createMessageRequest = BinaryData.fromObject(createMessageRequestObj); + return createMessageWithResponse(threadId, createMessageRequest, requestOptions).getValue() + .toObject(ThreadMessage.class); + } + + /** + * Creates a new message on a specified thread. + * + * @param threadId Identifier of the thread. + * @param role The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + * @param content The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadMessage createMessage(String threadId, MessageRole role, BinaryData content) { + // Generated convenience method for createMessageWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateMessageRequest createMessageRequestObj = new CreateMessageRequest(role, content); + BinaryData createMessageRequest = BinaryData.fromObject(createMessageRequestObj); + return createMessageWithResponse(threadId, createMessageRequest, requestOptions).getValue() + .toObject(ThreadMessage.class); + } + + /** + * Gets a list of messages that exist on a thread. + * + * @param threadId Identifier of the thread. + * @param runId Filter messages by the run ID that generated them. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of messages that exist on a thread as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listMessages(String threadId, String runId, Integer limit, ListSortOrder order, + String after, String before) { + // Generated convenience method for listMessages + RequestOptions requestOptions = new RequestOptions(); + if (runId != null) { + requestOptions.addQueryParam("run_id", runId, false); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + return serviceClient.listMessages(threadId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ThreadMessage.class)); + } + + /** + * Gets a list of messages that exist on a thread. + * + * @param threadId Identifier of the thread. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of messages that exist on a thread as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listMessages(String threadId) { + // Generated convenience method for listMessages + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listMessages(threadId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ThreadMessage.class)); + } + + /** + * Retrieves an existing message. + * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadMessage getMessage(String threadId, String messageId) { + // Generated convenience method for getMessageWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMessageWithResponse(threadId, messageId, requestOptions).getValue().toObject(ThreadMessage.class); + } + + /** + * Modifies an existing message on an existing thread. + * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadMessage updateMessage(String threadId, String messageId, Map metadata) { + // Generated convenience method for updateMessageWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateMessageRequest updateMessageRequestObj = new UpdateMessageRequest().setMetadata(metadata); + BinaryData updateMessageRequest = BinaryData.fromObject(updateMessageRequestObj); + return updateMessageWithResponse(threadId, messageId, updateMessageRequest, requestOptions).getValue() + .toObject(ThreadMessage.class); + } + + /** + * Modifies an existing message on an existing thread. + * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadMessage updateMessage(String threadId, String messageId) { + // Generated convenience method for updateMessageWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateMessageRequest updateMessageRequestObj = new UpdateMessageRequest(); + BinaryData updateMessageRequest = BinaryData.fromObject(updateMessageRequestObj); + return updateMessageWithResponse(threadId, messageId, updateMessageRequest, requestOptions).getValue() + .toObject(ThreadMessage.class); + } + + /** + * Creates a new message on a specified thread. + * + * @param threadId Identifier of the thread. + * @param role The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + * @param content The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + * @param attachments A list of files attached to the message, and the tools they should be added to. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadMessage createMessage(String threadId, MessageRole role, String content, + List attachments, Map metadata) { + // Generated convenience method for createMessageWithResponse + BinaryData binaryContent = BinaryData.fromString(content); + return this.createMessage(threadId, role, binaryContent, attachments, metadata); + } + + /** + * Creates a new message on a specified thread. + * + * @param threadId Identifier of the thread. + * @param role The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + * @param content The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single, existing message within an agent thread. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadMessage createMessage(String threadId, MessageRole role, String content) { + // Generated convenience method for createMessageWithResponse + BinaryData binaryContent = BinaryData.fromString(content); + return this.createMessage(threadId, role, binaryContent); + } + + /** + * Gets a list of messages that exist on a thread. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
run_idStringNoFilter messages by the run ID that generated them.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of messages that exist on a thread as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listMessages(String threadId, RequestOptions requestOptions) { + return this.serviceClient.listMessages(threadId, requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationAsyncClient.java new file mode 100644 index 000000000000..9f567300e169 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationAsyncClient.java @@ -0,0 +1,998 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.PersistentAgentsAdministrationClientImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.implementation.models.CreateThreadAndRunRequest; +import com.azure.ai.agents.persistent.implementation.models.UpdateAgentRequest; +import com.azure.ai.agents.persistent.models.AgentDeletionStatus; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateThreadAndRunOptions; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.UpdateAgentOptions; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class, isAsync = true) +public final class PersistentAgentsAdministrationAsyncClient { + + @Generated + private final PersistentAgentsAdministrationClientImpl serviceClient; + + /** + * Initializes an instance of PersistentAgentsAdministrationAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PersistentAgentsAdministrationAsyncClient(PersistentAgentsAdministrationClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a new agent. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     model: String (Required)
+     *     name: String (Optional)
+     *     description: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createAgentRequest The createAgentRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createAgentWithResponse(BinaryData createAgentRequest, + RequestOptions requestOptions) { + return this.serviceClient.createAgentWithResponseAsync(createAgentRequest, requestOptions); + } + + /** + * Retrieves an existing agent. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param assistantId Identifier of the agent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAgentWithResponse(String assistantId, RequestOptions requestOptions) { + return this.serviceClient.getAgentWithResponseAsync(assistantId, requestOptions); + } + + /** + * Modifies an existing agent. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     model: String (Optional)
+     *     name: String (Optional)
+     *     description: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param assistantId The ID of the agent to modify. + * @param updateAgentRequest The updateAgentRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateAgentWithResponse(String assistantId, BinaryData updateAgentRequest, + RequestOptions requestOptions) { + return this.serviceClient.updateAgentWithResponseAsync(assistantId, updateAgentRequest, requestOptions); + } + + /** + * Deletes an agent. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param assistantId Identifier of the agent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the status of an agent deletion operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteAgentWithResponse(String assistantId, RequestOptions requestOptions) { + return this.serviceClient.deleteAgentWithResponseAsync(assistantId, requestOptions); + } + + /** + * Creates a new agent thread and immediately starts a run using that new thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     assistant_id: String (Required)
+     *     thread (Optional): {
+     *         messages (Optional): [
+     *              (Optional){
+     *                 role: String(user/assistant) (Required)
+     *                 content: BinaryData (Required)
+     *                 attachments (Optional): [
+     *                      (Optional){
+     *                         file_id: String (Optional)
+     *                         data_source (Optional): {
+     *                             uri: String (Required)
+     *                             type: String(uri_asset/id_asset) (Required)
+     *                         }
+     *                         tools (Required): [
+     *                             BinaryData (Required)
+     *                         ]
+     *                     }
+     *                 ]
+     *                 metadata (Optional): {
+     *                     String: String (Required)
+     *                 }
+     *             }
+     *         ]
+     *         tool_resources (Optional): {
+     *             code_interpreter (Optional): {
+     *                 file_ids (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 data_sources (Optional): [
+     *                     (recursive schema, see above)
+     *                 ]
+     *             }
+     *             file_search (Optional): {
+     *                 vector_store_ids (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 vector_stores (Optional): [
+     *                      (Optional){
+     *                         name: String (Required)
+     *                         configuration (Required): {
+     *                             data_sources (Required): [
+     *                                 (recursive schema, see above)
+     *                             ]
+     *                         }
+     *                     }
+     *                 ]
+     *             }
+     *             azure_ai_search (Optional): {
+     *                 indexes (Optional): [
+     *                      (Optional){
+     *                         index_connection_id: String (Required)
+     *                         index_name: String (Required)
+     *                         query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                         top_k: Integer (Optional)
+     *                         filter: String (Optional)
+     *                         index_asset_id: String (Optional)
+     *                     }
+     *                 ]
+     *             }
+     *         }
+     *         metadata (Optional): {
+     *             String: String (Required)
+     *         }
+     *     }
+     *     model: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): (recursive schema, see azure_ai_search above)
+     *     }
+     *     stream: Boolean (Optional)
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Optional)
+     *     max_completion_tokens: Integer (Optional)
+     *     truncation_strategy (Optional): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Optional)
+     *     response_format: BinaryData (Optional)
+     *     parallel_tool_calls: Boolean (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param createThreadAndRunRequest The createThreadAndRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createThreadAndRunWithResponse(BinaryData createThreadAndRunRequest, + RequestOptions requestOptions) { + return this.serviceClient.createThreadAndRunWithResponseAsync(createThreadAndRunRequest, requestOptions); + } + + /** + * Creates a new agent. + * + * @param options Options for createAgent API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an agent that can call the model and use tools on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createAgent(CreateAgentOptions options) { + // Generated convenience method for createAgentWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateAgentRequest createAgentRequestObj = new CreateAgentRequest(options.getModel()).setName(options.getName()) + .setDescription(options.getDescription()) + .setInstructions(options.getInstructions()) + .setTools(options.getTools()) + .setToolResources(options.getToolResources()) + .setTemperature(options.getTemperature()) + .setTopP(options.getTopP()) + .setResponseFormat(options.getResponseFormat()) + .setMetadata(options.getMetadata()); + BinaryData createAgentRequest = BinaryData.fromObject(createAgentRequestObj); + return createAgentWithResponse(createAgentRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgent.class)); + } + + /** + * Gets a list of agents that were previously created. + * + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of agents that were previously created as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAgents(Integer limit, ListSortOrder order, String after, String before) { + // Generated convenience method for listAgents + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + PagedFlux pagedFluxResponse = listAgents(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgent.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Gets a list of agents that were previously created. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of agents that were previously created as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAgents() { + // Generated convenience method for listAgents + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listAgents(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgent.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Retrieves an existing agent. + * + * @param assistantId Identifier of the agent. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an agent that can call the model and use tools on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getAgent(String assistantId) { + // Generated convenience method for getAgentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAgentWithResponse(assistantId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgent.class)); + } + + /** + * Modifies an existing agent. + * + * @param options Options for updateAgent API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an agent that can call the model and use tools on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateAgent(UpdateAgentOptions options) { + // Generated convenience method for updateAgentWithResponse + RequestOptions requestOptions = new RequestOptions(); + String assistantId = options.getAssistantId(); + UpdateAgentRequest updateAgentRequestObj = new UpdateAgentRequest().setModel(options.getModel()) + .setName(options.getName()) + .setDescription(options.getDescription()) + .setInstructions(options.getInstructions()) + .setTools(options.getTools()) + .setToolResources(options.getToolResources()) + .setTemperature(options.getTemperature()) + .setTopP(options.getTopP()) + .setResponseFormat(options.getResponseFormat()) + .setMetadata(options.getMetadata()); + BinaryData updateAgentRequest = BinaryData.fromObject(updateAgentRequestObj); + return updateAgentWithResponse(assistantId, updateAgentRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgent.class)); + } + + /** + * Deletes an agent. + * + * @param assistantId Identifier of the agent. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the status of an agent deletion operation on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteAgent(String assistantId) { + // Generated convenience method for deleteAgentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteAgentWithResponse(assistantId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentDeletionStatus.class)); + } + + /** + * Creates a new agent thread and immediately starts a run using that new thread. + * + * @param options Options for createThreadAndRun API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createThreadAndRun(CreateThreadAndRunOptions options) { + // Generated convenience method for createThreadAndRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateThreadAndRunRequest createThreadAndRunRequestObj + = new CreateThreadAndRunRequest(options.getAssistantId()).setThread(options.getThread()) + .setModel(options.getModel()) + .setInstructions(options.getInstructions()) + .setTools(options.getTools()) + .setToolResources(options.getToolResources()) + .setStream(options.isStream()) + .setTemperature(options.getTemperature()) + .setTopP(options.getTopP()) + .setMaxPromptTokens(options.getMaxPromptTokens()) + .setMaxCompletionTokens(options.getMaxCompletionTokens()) + .setTruncationStrategy(options.getTruncationStrategy()) + .setToolChoice(options.getToolChoice()) + .setResponseFormat(options.getResponseFormat()) + .setParallelToolCalls(options.isParallelToolCalls()) + .setMetadata(options.getMetadata()); + BinaryData createThreadAndRunRequest = BinaryData.fromObject(createThreadAndRunRequestObj); + return createThreadAndRunWithResponse(createThreadAndRunRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadRun.class)); + } + + /** + * Gets a list of agents that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of agents that were previously created as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAgents(RequestOptions requestOptions) { + return this.serviceClient.listAgentsAsync(requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClient.java new file mode 100644 index 000000000000..c53d2a7acd3e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClient.java @@ -0,0 +1,961 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.PersistentAgentsAdministrationClientImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.implementation.models.CreateThreadAndRunRequest; +import com.azure.ai.agents.persistent.implementation.models.UpdateAgentRequest; +import com.azure.ai.agents.persistent.models.AgentDeletionStatus; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateThreadAndRunOptions; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.UpdateAgentOptions; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; + +/** + * Initializes a new instance of the synchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class) +public final class PersistentAgentsAdministrationClient { + + @Generated + private final PersistentAgentsAdministrationClientImpl serviceClient; + + /** + * Initializes an instance of PersistentAgentsAdministrationClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + PersistentAgentsAdministrationClient(PersistentAgentsAdministrationClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a new agent. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     model: String (Required)
+     *     name: String (Optional)
+     *     description: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createAgentRequest The createAgentRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createAgentWithResponse(BinaryData createAgentRequest, RequestOptions requestOptions) { + return this.serviceClient.createAgentWithResponse(createAgentRequest, requestOptions); + } + + /** + * Retrieves an existing agent. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param assistantId Identifier of the agent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAgentWithResponse(String assistantId, RequestOptions requestOptions) { + return this.serviceClient.getAgentWithResponse(assistantId, requestOptions); + } + + /** + * Modifies an existing agent. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     model: String (Optional)
+     *     name: String (Optional)
+     *     description: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param assistantId The ID of the agent to modify. + * @param updateAgentRequest The updateAgentRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateAgentWithResponse(String assistantId, BinaryData updateAgentRequest, + RequestOptions requestOptions) { + return this.serviceClient.updateAgentWithResponse(assistantId, updateAgentRequest, requestOptions); + } + + /** + * Deletes an agent. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param assistantId Identifier of the agent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the status of an agent deletion operation along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteAgentWithResponse(String assistantId, RequestOptions requestOptions) { + return this.serviceClient.deleteAgentWithResponse(assistantId, requestOptions); + } + + /** + * Creates a new agent thread and immediately starts a run using that new thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     assistant_id: String (Required)
+     *     thread (Optional): {
+     *         messages (Optional): [
+     *              (Optional){
+     *                 role: String(user/assistant) (Required)
+     *                 content: BinaryData (Required)
+     *                 attachments (Optional): [
+     *                      (Optional){
+     *                         file_id: String (Optional)
+     *                         data_source (Optional): {
+     *                             uri: String (Required)
+     *                             type: String(uri_asset/id_asset) (Required)
+     *                         }
+     *                         tools (Required): [
+     *                             BinaryData (Required)
+     *                         ]
+     *                     }
+     *                 ]
+     *                 metadata (Optional): {
+     *                     String: String (Required)
+     *                 }
+     *             }
+     *         ]
+     *         tool_resources (Optional): {
+     *             code_interpreter (Optional): {
+     *                 file_ids (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 data_sources (Optional): [
+     *                     (recursive schema, see above)
+     *                 ]
+     *             }
+     *             file_search (Optional): {
+     *                 vector_store_ids (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 vector_stores (Optional): [
+     *                      (Optional){
+     *                         name: String (Required)
+     *                         configuration (Required): {
+     *                             data_sources (Required): [
+     *                                 (recursive schema, see above)
+     *                             ]
+     *                         }
+     *                     }
+     *                 ]
+     *             }
+     *             azure_ai_search (Optional): {
+     *                 indexes (Optional): [
+     *                      (Optional){
+     *                         index_connection_id: String (Required)
+     *                         index_name: String (Required)
+     *                         query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                         top_k: Integer (Optional)
+     *                         filter: String (Optional)
+     *                         index_asset_id: String (Optional)
+     *                     }
+     *                 ]
+     *             }
+     *         }
+     *         metadata (Optional): {
+     *             String: String (Required)
+     *         }
+     *     }
+     *     model: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): (recursive schema, see azure_ai_search above)
+     *     }
+     *     stream: Boolean (Optional)
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Optional)
+     *     max_completion_tokens: Integer (Optional)
+     *     truncation_strategy (Optional): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Optional)
+     *     response_format: BinaryData (Optional)
+     *     parallel_tool_calls: Boolean (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param createThreadAndRunRequest The createThreadAndRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createThreadAndRunWithResponse(BinaryData createThreadAndRunRequest, + RequestOptions requestOptions) { + return this.serviceClient.createThreadAndRunWithResponse(createThreadAndRunRequest, requestOptions); + } + + /** + * Creates a new agent. + * + * @param options Options for createAgent API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an agent that can call the model and use tools. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PersistentAgent createAgent(CreateAgentOptions options) { + // Generated convenience method for createAgentWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateAgentRequest createAgentRequestObj = new CreateAgentRequest(options.getModel()).setName(options.getName()) + .setDescription(options.getDescription()) + .setInstructions(options.getInstructions()) + .setTools(options.getTools()) + .setToolResources(options.getToolResources()) + .setTemperature(options.getTemperature()) + .setTopP(options.getTopP()) + .setResponseFormat(options.getResponseFormat()) + .setMetadata(options.getMetadata()); + BinaryData createAgentRequest = BinaryData.fromObject(createAgentRequestObj); + return createAgentWithResponse(createAgentRequest, requestOptions).getValue().toObject(PersistentAgent.class); + } + + /** + * Gets a list of agents that were previously created. + * + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of agents that were previously created as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listAgents(Integer limit, ListSortOrder order, String after, String before) { + // Generated convenience method for listAgents + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + return serviceClient.listAgents(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(PersistentAgent.class)); + } + + /** + * Gets a list of agents that were previously created. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of agents that were previously created as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listAgents() { + // Generated convenience method for listAgents + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listAgents(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(PersistentAgent.class)); + } + + /** + * Retrieves an existing agent. + * + * @param assistantId Identifier of the agent. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an agent that can call the model and use tools. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PersistentAgent getAgent(String assistantId) { + // Generated convenience method for getAgentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAgentWithResponse(assistantId, requestOptions).getValue().toObject(PersistentAgent.class); + } + + /** + * Modifies an existing agent. + * + * @param options Options for updateAgent API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return represents an agent that can call the model and use tools. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PersistentAgent updateAgent(UpdateAgentOptions options) { + // Generated convenience method for updateAgentWithResponse + RequestOptions requestOptions = new RequestOptions(); + String assistantId = options.getAssistantId(); + UpdateAgentRequest updateAgentRequestObj = new UpdateAgentRequest().setModel(options.getModel()) + .setName(options.getName()) + .setDescription(options.getDescription()) + .setInstructions(options.getInstructions()) + .setTools(options.getTools()) + .setToolResources(options.getToolResources()) + .setTemperature(options.getTemperature()) + .setTopP(options.getTopP()) + .setResponseFormat(options.getResponseFormat()) + .setMetadata(options.getMetadata()); + BinaryData updateAgentRequest = BinaryData.fromObject(updateAgentRequestObj); + return updateAgentWithResponse(assistantId, updateAgentRequest, requestOptions).getValue() + .toObject(PersistentAgent.class); + } + + /** + * Deletes an agent. + * + * @param assistantId Identifier of the agent. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the status of an agent deletion operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AgentDeletionStatus deleteAgent(String assistantId) { + // Generated convenience method for deleteAgentWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteAgentWithResponse(assistantId, requestOptions).getValue().toObject(AgentDeletionStatus.class); + } + + /** + * Creates a new agent thread and immediately starts a run using that new thread. + * + * @param options Options for createThreadAndRun API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadRun createThreadAndRun(CreateThreadAndRunOptions options) { + // Generated convenience method for createThreadAndRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateThreadAndRunRequest createThreadAndRunRequestObj + = new CreateThreadAndRunRequest(options.getAssistantId()).setThread(options.getThread()) + .setModel(options.getModel()) + .setInstructions(options.getInstructions()) + .setTools(options.getTools()) + .setToolResources(options.getToolResources()) + .setStream(options.isStream()) + .setTemperature(options.getTemperature()) + .setTopP(options.getTopP()) + .setMaxPromptTokens(options.getMaxPromptTokens()) + .setMaxCompletionTokens(options.getMaxCompletionTokens()) + .setTruncationStrategy(options.getTruncationStrategy()) + .setToolChoice(options.getToolChoice()) + .setResponseFormat(options.getResponseFormat()) + .setParallelToolCalls(options.isParallelToolCalls()) + .setMetadata(options.getMetadata()); + BinaryData createThreadAndRunRequest = BinaryData.fromObject(createThreadAndRunRequestObj); + return createThreadAndRunWithResponse(createThreadAndRunRequest, requestOptions).getValue() + .toObject(ThreadRun.class); + } + + /** + * Gets a list of agents that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of agents that were previously created as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listAgents(RequestOptions requestOptions) { + return this.serviceClient.listAgents(requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClientBuilder.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClientBuilder.java new file mode 100644 index 000000000000..02548121b138 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClientBuilder.java @@ -0,0 +1,538 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.PersistentAgentsAdministrationClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.EndpointTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.client.traits.KeyCredentialTrait; +import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.credential.KeyCredential; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.KeyCredentialPolicy; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * A builder for creating a new instance of the PersistentAgentsAdministrationClient type. + */ +@ServiceClientBuilder( + serviceClients = { + PersistentAgentsAdministrationClient.class, + ThreadsClient.class, + MessagesClient.class, + RunsClient.class, + RunStepsClient.class, + FilesClient.class, + VectorStoresClient.class, + VectorStoreFilesClient.class, + VectorStoreFileBatchesClient.class, + PersistentAgentsAdministrationAsyncClient.class, + ThreadsAsyncClient.class, + MessagesAsyncClient.class, + RunsAsyncClient.class, + RunStepsAsyncClient.class, + FilesAsyncClient.class, + VectorStoresAsyncClient.class, + VectorStoreFilesAsyncClient.class, + VectorStoreFileBatchesAsyncClient.class }) +public final class PersistentAgentsAdministrationClientBuilder + implements HttpTrait, + ConfigurationTrait, + TokenCredentialTrait, + KeyCredentialTrait, + EndpointTrait { + + @Generated + private static final String SDK_NAME = "name"; + + @Generated + private static final String SDK_VERSION = "version"; + + @Generated + private static final String[] DEFAULT_SCOPES = new String[] { "https://ai.azure.com/.default" }; + + @Generated + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-ai-agents-persistent.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the PersistentAgentsAdministrationClientBuilder. + */ + @Generated + public PersistentAgentsAdministrationClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PersistentAgentsAdministrationClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PersistentAgentsAdministrationClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PersistentAgentsAdministrationClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated + private ClientOptions clientOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PersistentAgentsAdministrationClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated + private RetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PersistentAgentsAdministrationClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PersistentAgentsAdministrationClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PersistentAgentsAdministrationClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated + private TokenCredential tokenCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PersistentAgentsAdministrationClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Generated + private KeyCredential keyCredential; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PersistentAgentsAdministrationClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public PersistentAgentsAdministrationClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Generated + private AgentsServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the PersistentAgentsAdministrationClientBuilder. + */ + @Generated + public PersistentAgentsAdministrationClientBuilder serviceVersion(AgentsServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated + private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the PersistentAgentsAdministrationClientBuilder. + */ + @Generated + public PersistentAgentsAdministrationClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of PersistentAgentsAdministrationClientImpl with the provided parameters. + * + * @return an instance of PersistentAgentsAdministrationClientImpl. + */ + @Generated + private PersistentAgentsAdministrationClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + AgentsServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : AgentsServiceVersion.getLatest(); + PersistentAgentsAdministrationClientImpl client = new PersistentAgentsAdministrationClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); + return client; + } + + @Generated + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); + if (headers != null) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + if (keyCredential != null) { + policies.add(new KeyCredentialPolicy("authorization", keyCredential, "Bearer")); + } + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of PersistentAgentsAdministrationAsyncClient class. + * + * @return an instance of PersistentAgentsAdministrationAsyncClient. + */ + @Generated + public PersistentAgentsAdministrationAsyncClient buildAsyncClient() { + return new PersistentAgentsAdministrationAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of ThreadsAsyncClient class. + * + * @return an instance of ThreadsAsyncClient. + */ + @Generated + public ThreadsAsyncClient buildThreadsAsyncClient() { + return new ThreadsAsyncClient(buildInnerClient().getThreads()); + } + + /** + * Builds an instance of MessagesAsyncClient class. + * + * @return an instance of MessagesAsyncClient. + */ + @Generated + public MessagesAsyncClient buildMessagesAsyncClient() { + return new MessagesAsyncClient(buildInnerClient().getMessages()); + } + + /** + * Builds an instance of RunsAsyncClient class. + * + * @return an instance of RunsAsyncClient. + */ + @Generated + public RunsAsyncClient buildRunsAsyncClient() { + return new RunsAsyncClient(buildInnerClient().getRuns()); + } + + /** + * Builds an instance of RunStepsAsyncClient class. + * + * @return an instance of RunStepsAsyncClient. + */ + @Generated + public RunStepsAsyncClient buildRunStepsAsyncClient() { + return new RunStepsAsyncClient(buildInnerClient().getRunSteps()); + } + + /** + * Builds an instance of FilesAsyncClient class. + * + * @return an instance of FilesAsyncClient. + */ + @Generated + public FilesAsyncClient buildFilesAsyncClient() { + return new FilesAsyncClient(buildInnerClient().getFiles()); + } + + /** + * Builds an instance of VectorStoresAsyncClient class. + * + * @return an instance of VectorStoresAsyncClient. + */ + @Generated + public VectorStoresAsyncClient buildVectorStoresAsyncClient() { + return new VectorStoresAsyncClient(buildInnerClient().getVectorStores()); + } + + /** + * Builds an instance of VectorStoreFilesAsyncClient class. + * + * @return an instance of VectorStoreFilesAsyncClient. + */ + @Generated + public VectorStoreFilesAsyncClient buildVectorStoreFilesAsyncClient() { + return new VectorStoreFilesAsyncClient(buildInnerClient().getVectorStoreFiles()); + } + + /** + * Builds an instance of VectorStoreFileBatchesAsyncClient class. + * + * @return an instance of VectorStoreFileBatchesAsyncClient. + */ + @Generated + public VectorStoreFileBatchesAsyncClient buildVectorStoreFileBatchesAsyncClient() { + return new VectorStoreFileBatchesAsyncClient(buildInnerClient().getVectorStoreFileBatches()); + } + + /** + * Builds an instance of PersistentAgentsAdministrationClient class. + * + * @return an instance of PersistentAgentsAdministrationClient. + */ + @Generated + public PersistentAgentsAdministrationClient buildClient() { + return new PersistentAgentsAdministrationClient(buildInnerClient()); + } + + /** + * Builds an instance of ThreadsClient class. + * + * @return an instance of ThreadsClient. + */ + @Generated + public ThreadsClient buildThreadsClient() { + return new ThreadsClient(buildInnerClient().getThreads()); + } + + /** + * Builds an instance of MessagesClient class. + * + * @return an instance of MessagesClient. + */ + @Generated + public MessagesClient buildMessagesClient() { + return new MessagesClient(buildInnerClient().getMessages()); + } + + /** + * Builds an instance of RunsClient class. + * + * @return an instance of RunsClient. + */ + @Generated + public RunsClient buildRunsClient() { + return new RunsClient(buildInnerClient().getRuns()); + } + + /** + * Builds an instance of RunStepsClient class. + * + * @return an instance of RunStepsClient. + */ + @Generated + public RunStepsClient buildRunStepsClient() { + return new RunStepsClient(buildInnerClient().getRunSteps()); + } + + /** + * Builds an instance of FilesClient class. + * + * @return an instance of FilesClient. + */ + @Generated + public FilesClient buildFilesClient() { + return new FilesClient(buildInnerClient().getFiles()); + } + + /** + * Builds an instance of VectorStoresClient class. + * + * @return an instance of VectorStoresClient. + */ + @Generated + public VectorStoresClient buildVectorStoresClient() { + return new VectorStoresClient(buildInnerClient().getVectorStores()); + } + + /** + * Builds an instance of VectorStoreFilesClient class. + * + * @return an instance of VectorStoreFilesClient. + */ + @Generated + public VectorStoreFilesClient buildVectorStoreFilesClient() { + return new VectorStoreFilesClient(buildInnerClient().getVectorStoreFiles()); + } + + /** + * Builds an instance of VectorStoreFileBatchesClient class. + * + * @return an instance of VectorStoreFileBatchesClient. + */ + @Generated + public VectorStoreFileBatchesClient buildVectorStoreFileBatchesClient() { + return new VectorStoreFileBatchesClient(buildInnerClient().getVectorStoreFileBatches()); + } + + private static final ClientLogger LOGGER = new ClientLogger(PersistentAgentsAdministrationClientBuilder.class); +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunStepsAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunStepsAsyncClient.java new file mode 100644 index 000000000000..2270edf48520 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunStepsAsyncClient.java @@ -0,0 +1,345 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.RunStepsImpl; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.RunAdditionalFieldList; +import com.azure.ai.agents.persistent.models.RunStep; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class, isAsync = true) +public final class RunStepsAsyncClient { + + @Generated + private final RunStepsImpl serviceClient; + + /** + * Initializes an instance of RunStepsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RunStepsAsyncClient(RunStepsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Retrieves a single run step from a thread run. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     type: String(message_creation/tool_calls) (Required)
+     *     assistant_id: String (Required)
+     *     thread_id: String (Required)
+     *     run_id: String (Required)
+     *     status: String(in_progress/cancelled/failed/completed/expired) (Required)
+     *     step_details (Required): {
+     *         type: String(message_creation/tool_calls) (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String(server_error/rate_limit_exceeded) (Required)
+     *         message: String (Required)
+     *     }
+     *     created_at: long (Required)
+     *     expired_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     usage (Optional): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param stepId Identifier of the run step. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed information about a single step of an agent thread run along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRunStepWithResponse(String threadId, String runId, String stepId, + RequestOptions requestOptions) { + return this.serviceClient.getRunStepWithResponseAsync(threadId, runId, stepId, requestOptions); + } + + /** + * Retrieves a single run step from a thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param stepId Identifier of the run step. + * @param include A list of additional fields to include in the response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return detailed information about a single step of an agent thread run on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getRunStep(String threadId, String runId, String stepId, + List include) { + // Generated convenience method for getRunStepWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (include != null) { + requestOptions.addQueryParam("include[]", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return getRunStepWithResponse(threadId, runId, stepId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(RunStep.class)); + } + + /** + * Retrieves a single run step from a thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param stepId Identifier of the run step. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return detailed information about a single step of an agent thread run on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getRunStep(String threadId, String runId, String stepId) { + // Generated convenience method for getRunStepWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRunStepWithResponse(threadId, runId, stepId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(RunStep.class)); + } + + /** + * Gets a list of run steps from a thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param include A list of additional fields to include in the response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of run steps from a thread run as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRunSteps(String threadId, String runId, List include, + Integer limit, ListSortOrder order, String after, String before) { + // Generated convenience method for listRunSteps + RequestOptions requestOptions = new RequestOptions(); + if (include != null) { + requestOptions.addQueryParam("include[]", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + PagedFlux pagedFluxResponse = listRunSteps(threadId, runId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(RunStep.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Gets a list of run steps from a thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of run steps from a thread run as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRunSteps(String threadId, String runId) { + // Generated convenience method for listRunSteps + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listRunSteps(threadId, runId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(RunStep.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Gets a list of run steps from a thread run. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. In the form of "," separated string.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     type: String(message_creation/tool_calls) (Required)
+     *     assistant_id: String (Required)
+     *     thread_id: String (Required)
+     *     run_id: String (Required)
+     *     status: String(in_progress/cancelled/failed/completed/expired) (Required)
+     *     step_details (Required): {
+     *         type: String(message_creation/tool_calls) (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String(server_error/rate_limit_exceeded) (Required)
+     *         message: String (Required)
+     *     }
+     *     created_at: long (Required)
+     *     expired_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     usage (Optional): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of run steps from a thread run as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRunSteps(String threadId, String runId, RequestOptions requestOptions) { + return this.serviceClient.listRunStepsAsync(threadId, runId, requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunStepsClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunStepsClient.java new file mode 100644 index 000000000000..b5dbacc0e38b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunStepsClient.java @@ -0,0 +1,314 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.RunStepsImpl; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.RunAdditionalFieldList; +import com.azure.ai.agents.persistent.models.RunStep; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Initializes a new instance of the synchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class) +public final class RunStepsClient { + + @Generated + private final RunStepsImpl serviceClient; + + /** + * Initializes an instance of RunStepsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RunStepsClient(RunStepsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Retrieves a single run step from a thread run. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     type: String(message_creation/tool_calls) (Required)
+     *     assistant_id: String (Required)
+     *     thread_id: String (Required)
+     *     run_id: String (Required)
+     *     status: String(in_progress/cancelled/failed/completed/expired) (Required)
+     *     step_details (Required): {
+     *         type: String(message_creation/tool_calls) (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String(server_error/rate_limit_exceeded) (Required)
+     *         message: String (Required)
+     *     }
+     *     created_at: long (Required)
+     *     expired_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     usage (Optional): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param stepId Identifier of the run step. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed information about a single step of an agent thread run along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRunStepWithResponse(String threadId, String runId, String stepId, + RequestOptions requestOptions) { + return this.serviceClient.getRunStepWithResponse(threadId, runId, stepId, requestOptions); + } + + /** + * Retrieves a single run step from a thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param stepId Identifier of the run step. + * @param include A list of additional fields to include in the response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return detailed information about a single step of an agent thread run. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public RunStep getRunStep(String threadId, String runId, String stepId, List include) { + // Generated convenience method for getRunStepWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (include != null) { + requestOptions.addQueryParam("include[]", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return getRunStepWithResponse(threadId, runId, stepId, requestOptions).getValue().toObject(RunStep.class); + } + + /** + * Retrieves a single run step from a thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param stepId Identifier of the run step. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return detailed information about a single step of an agent thread run. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public RunStep getRunStep(String threadId, String runId, String stepId) { + // Generated convenience method for getRunStepWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRunStepWithResponse(threadId, runId, stepId, requestOptions).getValue().toObject(RunStep.class); + } + + /** + * Gets a list of run steps from a thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param include A list of additional fields to include in the response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of run steps from a thread run as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRunSteps(String threadId, String runId, List include, + Integer limit, ListSortOrder order, String after, String before) { + // Generated convenience method for listRunSteps + RequestOptions requestOptions = new RequestOptions(); + if (include != null) { + requestOptions.addQueryParam("include[]", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + return serviceClient.listRunSteps(threadId, runId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(RunStep.class)); + } + + /** + * Gets a list of run steps from a thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of run steps from a thread run as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRunSteps(String threadId, String runId) { + // Generated convenience method for listRunSteps + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listRunSteps(threadId, runId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(RunStep.class)); + } + + /** + * Gets a list of run steps from a thread run. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. In the form of "," separated string.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     type: String(message_creation/tool_calls) (Required)
+     *     assistant_id: String (Required)
+     *     thread_id: String (Required)
+     *     run_id: String (Required)
+     *     status: String(in_progress/cancelled/failed/completed/expired) (Required)
+     *     step_details (Required): {
+     *         type: String(message_creation/tool_calls) (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String(server_error/rate_limit_exceeded) (Required)
+     *         message: String (Required)
+     *     }
+     *     created_at: long (Required)
+     *     expired_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     usage (Optional): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of run steps from a thread run as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRunSteps(String threadId, String runId, RequestOptions requestOptions) { + return this.serviceClient.listRunSteps(threadId, runId, requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java new file mode 100644 index 000000000000..d2729573c4f0 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java @@ -0,0 +1,1125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.RunsImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateRunRequest; +import com.azure.ai.agents.persistent.implementation.models.SubmitToolOutputsToRunRequest; +import com.azure.ai.agents.persistent.implementation.models.UpdateRunRequest; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.RunAdditionalFieldList; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolOutput; +import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.ai.agents.persistent.models.streaming.PersistentAgentServerSentEvents; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class, isAsync = true) +public final class RunsAsyncClient { + + @Generated + private final RunsImpl serviceClient; + + /** + * Initializes an instance of RunsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RunsAsyncClient(RunsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a new run for an agent thread. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + * to fetch the file search result content. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     assistant_id: String (Required)
+     *     model: String (Optional)
+     *     instructions: String (Optional)
+     *     additional_instructions: String (Optional)
+     *     additional_messages (Optional): [
+     *          (Optional){
+     *             role: String(user/assistant) (Required)
+     *             content: BinaryData (Required)
+     *             attachments (Optional): [
+     *                  (Optional){
+     *                     file_id: String (Optional)
+     *                     data_source (Optional): {
+     *                         uri: String (Required)
+     *                         type: String(uri_asset/id_asset) (Required)
+     *                     }
+     *                     tools (Required): [
+     *                         BinaryData (Required)
+     *                     ]
+     *                 }
+     *             ]
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     stream: Boolean (Optional)
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Optional)
+     *     max_completion_tokens: Integer (Optional)
+     *     truncation_strategy (Optional): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Optional)
+     *     response_format: BinaryData (Optional)
+     *     parallel_tool_calls: Boolean (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param createRunRequest The createRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createRunWithResponse(String threadId, BinaryData createRunRequest, + RequestOptions requestOptions) { + return this.serviceClient.createRunWithResponseAsync(threadId, createRunRequest, requestOptions); + } + + /** + * Gets an existing run from an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an existing run from an existing thread along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRunWithResponse(String threadId, String runId, RequestOptions requestOptions) { + return this.serviceClient.getRunWithResponseAsync(threadId, runId, requestOptions); + } + + /** + * Modifies an existing thread run. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param updateRunRequest The updateRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateRunWithResponse(String threadId, String runId, BinaryData updateRunRequest, + RequestOptions requestOptions) { + return this.serviceClient.updateRunWithResponseAsync(threadId, runId, updateRunRequest, requestOptions); + } + + /** + * Submits outputs from tools as requested by tool calls in a run. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     tool_outputs (Required): [
+     *          (Required){
+     *             tool_call_id: String (Optional)
+     *             output: String (Optional)
+     *         }
+     *     ]
+     *     stream: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param submitToolOutputsToRunRequest The submitToolOutputsToRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> submitToolOutputsToRunWithResponse(String threadId, String runId, + BinaryData submitToolOutputsToRunRequest, RequestOptions requestOptions) { + return this.serviceClient.submitToolOutputsToRunWithResponseAsync(threadId, runId, + submitToolOutputsToRunRequest, requestOptions); + } + + /** + * Cancels a run of an in‐progress thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> cancelRunWithResponse(String threadId, String runId, + RequestOptions requestOptions) { + return this.serviceClient.cancelRunWithResponseAsync(threadId, runId, requestOptions); + } + + /** + * Creates a new run for an agent thread. + * + * @param options Options for createRun API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createRun(CreateRunOptions options) { + // Generated convenience method for createRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + String threadId = options.getThreadId(); + List include = options.getInclude(); + CreateRunRequest createRunRequestObj + = new CreateRunRequest(options.getAssistantId()).setModel(options.getModel()) + .setInstructions(options.getInstructions()) + .setAdditionalInstructions(options.getAdditionalInstructions()) + .setAdditionalMessages(options.getAdditionalMessages()) + .setTools(options.getTools()) + .setStream(options.isStream()) + .setTemperature(options.getTemperature()) + .setTopP(options.getTopP()) + .setMaxPromptTokens(options.getMaxPromptTokens()) + .setMaxCompletionTokens(options.getMaxCompletionTokens()) + .setTruncationStrategy(options.getTruncationStrategy()) + .setToolChoice(options.getToolChoice()) + .setResponseFormat(options.getResponseFormat()) + .setParallelToolCalls(options.isParallelToolCalls()) + .setMetadata(options.getMetadata()); + BinaryData createRunRequest = BinaryData.fromObject(createRunRequestObj); + if (include != null) { + requestOptions.addQueryParam("include[]", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return createRunWithResponse(threadId, createRunRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadRun.class)); + } + + /** + * Creates a new streaming run for an agent thread. + * + * @param options Options for createRun API. + * @return A mono of flux streaming updates from the run. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createRunStreaming(CreateRunOptions options) { + // Generated convenience method for createRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + String threadId = options.getThreadId(); + List include = options.getInclude(); + CreateRunRequest createRunRequestObj + = new CreateRunRequest(options.getAssistantId()).setModel(options.getModel()) + .setInstructions(options.getInstructions()) + .setAdditionalInstructions(options.getAdditionalInstructions()) + .setAdditionalMessages(options.getAdditionalMessages()) + .setTools(options.getTools()) + .setStream(true) + .setTemperature(options.getTemperature()) + .setTopP(options.getTopP()) + .setMaxPromptTokens(options.getMaxPromptTokens()) + .setMaxCompletionTokens(options.getMaxCompletionTokens()) + .setTruncationStrategy(options.getTruncationStrategy()) + .setToolChoice(options.getToolChoice()) + .setResponseFormat(options.getResponseFormat()) + .setParallelToolCalls(options.isParallelToolCalls()) + .setMetadata(options.getMetadata()); + BinaryData createRunRequest = BinaryData.fromObject(createRunRequestObj); + if (include != null) { + requestOptions.addQueryParam("include[]", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + + return createRunWithResponse(threadId, createRunRequest, requestOptions).map(response -> { + PersistentAgentServerSentEvents eventStream + = new PersistentAgentServerSentEvents(response.getValue().toFluxByteBuffer()); + return eventStream.getEvents(); + }); + } + + /** + * Gets a list of runs for a specified thread. + * + * @param threadId Identifier of the thread. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of runs for a specified thread as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRuns(String threadId, Integer limit, ListSortOrder order, String after, + String before) { + // Generated convenience method for listRuns + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + PagedFlux pagedFluxResponse = listRuns(threadId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ThreadRun.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Gets a list of runs for a specified thread. + * + * @param threadId Identifier of the thread. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of runs for a specified thread as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRuns(String threadId) { + // Generated convenience method for listRuns + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listRuns(threadId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(ThreadRun.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Gets an existing run from an existing thread. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an existing run from an existing thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getRun(String threadId, String runId) { + // Generated convenience method for getRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRunWithResponse(threadId, runId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadRun.class)); + } + + /** + * Modifies an existing thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateRun(String threadId, String runId, Map metadata) { + // Generated convenience method for updateRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateRunRequest updateRunRequestObj = new UpdateRunRequest().setMetadata(metadata); + BinaryData updateRunRequest = BinaryData.fromObject(updateRunRequestObj); + return updateRunWithResponse(threadId, runId, updateRunRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadRun.class)); + } + + /** + * Modifies an existing thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateRun(String threadId, String runId) { + // Generated convenience method for updateRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateRunRequest updateRunRequestObj = new UpdateRunRequest(); + BinaryData updateRunRequest = BinaryData.fromObject(updateRunRequestObj); + return updateRunWithResponse(threadId, runId, updateRunRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadRun.class)); + } + + /** + * Submits outputs from tools as requested by tool calls in a run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param toolOutputs A list of tools for which the outputs are being submitted. + * @param stream If true, returns a stream of events that happen during the Run as SSE, terminating at `[DONE]`. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono submitToolOutputsToRun(String threadId, String runId, List toolOutputs, + Boolean stream) { + // Generated convenience method for submitToolOutputsToRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequestObj + = new SubmitToolOutputsToRunRequest(toolOutputs).setStream(stream); + BinaryData submitToolOutputsToRunRequest = BinaryData.fromObject(submitToolOutputsToRunRequestObj); + return submitToolOutputsToRunWithResponse(threadId, runId, submitToolOutputsToRunRequest, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadRun.class)); + } + + /** + * Submits outputs from tools as requested by tool calls in a run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param toolOutputs A list of tools for which the outputs are being submitted. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono submitToolOutputsToRun(String threadId, String runId, List toolOutputs) { + // Generated convenience method for submitToolOutputsToRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequestObj = new SubmitToolOutputsToRunRequest(toolOutputs); + BinaryData submitToolOutputsToRunRequest = BinaryData.fromObject(submitToolOutputsToRunRequestObj); + return submitToolOutputsToRunWithResponse(threadId, runId, submitToolOutputsToRunRequest, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadRun.class)); + } + + /** + * Submits outputs from tools as requested by tool calls in a run with streaming updates. + * Runs that need submitted tool outputs will have a status of 'requires_action' + * with a required_action.type of 'submit_tool_outputs'. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param toolOutputs A list of tools for which the outputs are being submitted. + * @return A mono of flux of streaming updates from the run. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> submitToolOutputsToRunStreaming(String threadId, String runId, + List toolOutputs) { + RequestOptions requestOptions = new RequestOptions(); + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequestObj + = new SubmitToolOutputsToRunRequest(toolOutputs).setStream(true); + BinaryData submitToolOutputsToRunRequest = BinaryData.fromObject(submitToolOutputsToRunRequestObj); + + return submitToolOutputsToRunWithResponse(threadId, runId, submitToolOutputsToRunRequest, requestOptions) + .map(response -> { + PersistentAgentServerSentEvents eventStream + = new PersistentAgentServerSentEvents(response.getValue().toFluxByteBuffer()); + return eventStream.getEvents(); + }); + } + + /** + * Cancels a run of an in‐progress thread. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono cancelRun(String threadId, String runId) { + // Generated convenience method for cancelRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + return cancelRunWithResponse(threadId, runId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadRun.class)); + } + + /** + * Gets a list of runs for a specified thread. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of runs for a specified thread as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRuns(String threadId, RequestOptions requestOptions) { + return this.serviceClient.listRunsAsync(threadId, requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java new file mode 100644 index 000000000000..7cacef5044c9 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java @@ -0,0 +1,1089 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.RunsImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateRunRequest; +import com.azure.ai.agents.persistent.implementation.models.SubmitToolOutputsToRunRequest; +import com.azure.ai.agents.persistent.implementation.models.UpdateRunRequest; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.RunAdditionalFieldList; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolOutput; +import com.azure.ai.agents.persistent.models.streaming.PersistentAgentServerSentEvents; +import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import java.nio.ByteBuffer; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; + +/** + * Initializes a new instance of the synchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class) +public final class RunsClient { + + @Generated + private final RunsImpl serviceClient; + + /** + * Initializes an instance of RunsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + RunsClient(RunsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a new run for an agent thread. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + * to fetch the file search result content. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     assistant_id: String (Required)
+     *     model: String (Optional)
+     *     instructions: String (Optional)
+     *     additional_instructions: String (Optional)
+     *     additional_messages (Optional): [
+     *          (Optional){
+     *             role: String(user/assistant) (Required)
+     *             content: BinaryData (Required)
+     *             attachments (Optional): [
+     *                  (Optional){
+     *                     file_id: String (Optional)
+     *                     data_source (Optional): {
+     *                         uri: String (Required)
+     *                         type: String(uri_asset/id_asset) (Required)
+     *                     }
+     *                     tools (Required): [
+     *                         BinaryData (Required)
+     *                     ]
+     *                 }
+     *             ]
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     stream: Boolean (Optional)
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Optional)
+     *     max_completion_tokens: Integer (Optional)
+     *     truncation_strategy (Optional): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Optional)
+     *     response_format: BinaryData (Optional)
+     *     parallel_tool_calls: Boolean (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param createRunRequest The createRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createRunWithResponse(String threadId, BinaryData createRunRequest, + RequestOptions requestOptions) { + return this.serviceClient.createRunWithResponse(threadId, createRunRequest, requestOptions); + } + + /** + * Gets an existing run from an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an existing run from an existing thread along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRunWithResponse(String threadId, String runId, RequestOptions requestOptions) { + return this.serviceClient.getRunWithResponse(threadId, runId, requestOptions); + } + + /** + * Modifies an existing thread run. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param updateRunRequest The updateRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateRunWithResponse(String threadId, String runId, BinaryData updateRunRequest, + RequestOptions requestOptions) { + return this.serviceClient.updateRunWithResponse(threadId, runId, updateRunRequest, requestOptions); + } + + /** + * Submits outputs from tools as requested by tool calls in a run. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     tool_outputs (Required): [
+     *          (Required){
+     *             tool_call_id: String (Optional)
+     *             output: String (Optional)
+     *         }
+     *     ]
+     *     stream: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param submitToolOutputsToRunRequest The submitToolOutputsToRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response submitToolOutputsToRunWithResponse(String threadId, String runId, + BinaryData submitToolOutputsToRunRequest, RequestOptions requestOptions) { + return this.serviceClient.submitToolOutputsToRunWithResponse(threadId, runId, submitToolOutputsToRunRequest, + requestOptions); + } + + /** + * Cancels a run of an in‐progress thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response cancelRunWithResponse(String threadId, String runId, RequestOptions requestOptions) { + return this.serviceClient.cancelRunWithResponse(threadId, runId, requestOptions); + } + + /** + * Creates a new run for an agent thread. + * + * @param options Options for createRun API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadRun createRun(CreateRunOptions options) { + // Generated convenience method for createRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + String threadId = options.getThreadId(); + List include = options.getInclude(); + CreateRunRequest createRunRequestObj + = new CreateRunRequest(options.getAssistantId()).setModel(options.getModel()) + .setInstructions(options.getInstructions()) + .setAdditionalInstructions(options.getAdditionalInstructions()) + .setAdditionalMessages(options.getAdditionalMessages()) + .setTools(options.getTools()) + .setStream(options.isStream()) + .setTemperature(options.getTemperature()) + .setTopP(options.getTopP()) + .setMaxPromptTokens(options.getMaxPromptTokens()) + .setMaxCompletionTokens(options.getMaxCompletionTokens()) + .setTruncationStrategy(options.getTruncationStrategy()) + .setToolChoice(options.getToolChoice()) + .setResponseFormat(options.getResponseFormat()) + .setParallelToolCalls(options.isParallelToolCalls()) + .setMetadata(options.getMetadata()); + BinaryData createRunRequest = BinaryData.fromObject(createRunRequestObj); + if (include != null) { + requestOptions.addQueryParam("include[]", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + return createRunWithResponse(threadId, createRunRequest, requestOptions).getValue().toObject(ThreadRun.class); + } + + /** + * Gets a list of runs for a specified thread. + * + * @param threadId Identifier of the thread. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of runs for a specified thread as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRuns(String threadId, Integer limit, ListSortOrder order, String after, + String before) { + // Generated convenience method for listRuns + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + return serviceClient.listRuns(threadId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ThreadRun.class)); + } + + /** + * Gets a list of runs for a specified thread. + * + * @param threadId Identifier of the thread. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of runs for a specified thread as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRuns(String threadId) { + // Generated convenience method for listRuns + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listRuns(threadId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ThreadRun.class)); + } + + /** + * Gets an existing run from an existing thread. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an existing run from an existing thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadRun getRun(String threadId, String runId) { + // Generated convenience method for getRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRunWithResponse(threadId, runId, requestOptions).getValue().toObject(ThreadRun.class); + } + + /** + * Modifies an existing thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadRun updateRun(String threadId, String runId, Map metadata) { + // Generated convenience method for updateRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateRunRequest updateRunRequestObj = new UpdateRunRequest().setMetadata(metadata); + BinaryData updateRunRequest = BinaryData.fromObject(updateRunRequestObj); + return updateRunWithResponse(threadId, runId, updateRunRequest, requestOptions).getValue() + .toObject(ThreadRun.class); + } + + /** + * Modifies an existing thread run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadRun updateRun(String threadId, String runId) { + // Generated convenience method for updateRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateRunRequest updateRunRequestObj = new UpdateRunRequest(); + BinaryData updateRunRequest = BinaryData.fromObject(updateRunRequestObj); + return updateRunWithResponse(threadId, runId, updateRunRequest, requestOptions).getValue() + .toObject(ThreadRun.class); + } + + /** + * Submits outputs from tools as requested by tool calls in a run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param toolOutputs A list of tools for which the outputs are being submitted. + * @param stream If true, returns a stream of events that happen during the Run as SSE, terminating at `[DONE]`. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadRun submitToolOutputsToRun(String threadId, String runId, List toolOutputs, + Boolean stream) { + // Generated convenience method for submitToolOutputsToRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequestObj + = new SubmitToolOutputsToRunRequest(toolOutputs).setStream(stream); + BinaryData submitToolOutputsToRunRequest = BinaryData.fromObject(submitToolOutputsToRunRequestObj); + return submitToolOutputsToRunWithResponse(threadId, runId, submitToolOutputsToRunRequest, requestOptions) + .getValue() + .toObject(ThreadRun.class); + } + + /** + * Submits outputs from tools as requested by tool calls in a run. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param toolOutputs A list of tools for which the outputs are being submitted. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadRun submitToolOutputsToRun(String threadId, String runId, List toolOutputs) { + // Generated convenience method for submitToolOutputsToRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequestObj = new SubmitToolOutputsToRunRequest(toolOutputs); + BinaryData submitToolOutputsToRunRequest = BinaryData.fromObject(submitToolOutputsToRunRequestObj); + return submitToolOutputsToRunWithResponse(threadId, runId, submitToolOutputsToRunRequest, requestOptions) + .getValue() + .toObject(ThreadRun.class); + } + + /** + * Cancels a run of an in‐progress thread. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return data representing a single evaluation run of an agent thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadRun cancelRun(String threadId, String runId) { + // Generated convenience method for cancelRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + return cancelRunWithResponse(threadId, runId, requestOptions).getValue().toObject(ThreadRun.class); + } + + /** + * Creates a new streaming run for an agent thread. + * + * @param options Options for createRun API. + * @return data representing a single evaluation run of an agent thread. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Flux createRunStreaming(CreateRunOptions options) { + // Generated convenience method for createRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + String threadId = options.getThreadId(); + List include = options.getInclude(); + CreateRunRequest createRunRequestObj + = new CreateRunRequest(options.getAssistantId()).setModel(options.getModel()) + .setInstructions(options.getInstructions()) + .setAdditionalInstructions(options.getAdditionalInstructions()) + .setAdditionalMessages(options.getAdditionalMessages()) + .setTools(options.getTools()) + .setStream(true) + .setTemperature(options.getTemperature()) + .setTopP(options.getTopP()) + .setMaxPromptTokens(options.getMaxPromptTokens()) + .setMaxCompletionTokens(options.getMaxCompletionTokens()) + .setTruncationStrategy(options.getTruncationStrategy()) + .setToolChoice(options.getToolChoice()) + .setResponseFormat(options.getResponseFormat()) + .setParallelToolCalls(options.isParallelToolCalls()) + .setMetadata(options.getMetadata()); + BinaryData createRunRequest = BinaryData.fromObject(createRunRequestObj); + if (include != null) { + requestOptions.addQueryParam("include[]", + include.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")), + false); + } + Flux response + = createRunWithResponse(threadId, createRunRequest, requestOptions).getValue().toFluxByteBuffer(); + PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response); + return eventStream.getEvents(); + } + + /** + * Submits outputs from tools as requested by tool calls in a run with streaming updates. + * Runs that need submitted tool outputs will have a status of 'requires_action' + * with a required_action.type of 'submit_tool_outputs'. + * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param toolOutputs A list of tools for which the outputs are being submitted. + * @return data representing a single evaluation run of an agent thread. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Flux submitToolOutputsToRunStreaming(String threadId, String runId, + List toolOutputs) { + // Generated convenience method for submitToolOutputsToRunWithResponse + RequestOptions requestOptions = new RequestOptions(); + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequestObj + = new SubmitToolOutputsToRunRequest(toolOutputs).setStream(true); + BinaryData submitToolOutputsToRunRequest = BinaryData.fromObject(submitToolOutputsToRunRequestObj); + Flux response + = submitToolOutputsToRunWithResponse(threadId, runId, submitToolOutputsToRunRequest, requestOptions) + .getValue() + .toFluxByteBuffer(); + PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response); + return eventStream.getEvents(); + } + + /** + * Gets a list of runs for a specified thread. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of runs for a specified thread as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRuns(String threadId, RequestOptions requestOptions) { + return this.serviceClient.listRuns(threadId, requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/ThreadsAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/ThreadsAsyncClient.java new file mode 100644 index 000000000000..b947c5ed88eb --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/ThreadsAsyncClient.java @@ -0,0 +1,748 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.ThreadsImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateThreadRequest; +import com.azure.ai.agents.persistent.implementation.models.UpdateThreadRequest; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadDeletionStatus; +import com.azure.ai.agents.persistent.models.ThreadMessageOptions; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class, isAsync = true) +public final class ThreadsAsyncClient { + + @Generated + private final ThreadsImpl serviceClient; + + /** + * Initializes an instance of ThreadsAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ThreadsAsyncClient(ThreadsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a new thread. Threads contain messages and can be run by agents. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     messages (Optional): [
+     *          (Optional){
+     *             role: String(user/assistant) (Required)
+     *             content: BinaryData (Required)
+     *             attachments (Optional): [
+     *                  (Optional){
+     *                     file_id: String (Optional)
+     *                     data_source (Optional): {
+     *                         uri: String (Required)
+     *                         type: String(uri_asset/id_asset) (Required)
+     *                     }
+     *                     tools (Required): [
+     *                         BinaryData (Required)
+     *                     ]
+     *                 }
+     *             ]
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                 (recursive schema, see above)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createThreadRequest The createThreadRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about a single thread associated with an agent along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createThreadWithResponse(BinaryData createThreadRequest, + RequestOptions requestOptions) { + return this.serviceClient.createThreadWithResponseAsync(createThreadRequest, requestOptions); + } + + /** + * Gets information about an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about an existing thread along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getThreadWithResponse(String threadId, RequestOptions requestOptions) { + return this.serviceClient.getThreadWithResponseAsync(threadId, requestOptions); + } + + /** + * Modifies an existing thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId The ID of the thread to modify. + * @param updateThreadRequest The updateThreadRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about a single thread associated with an agent along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateThreadWithResponse(String threadId, BinaryData updateThreadRequest, + RequestOptions requestOptions) { + return this.serviceClient.updateThreadWithResponseAsync(threadId, updateThreadRequest, requestOptions); + } + + /** + * Deletes an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the status of a thread deletion operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteThreadWithResponse(String threadId, RequestOptions requestOptions) { + return this.serviceClient.deleteThreadWithResponseAsync(threadId, requestOptions); + } + + /** + * Creates a new thread. Threads contain messages and can be run by agents. + * + * @param messages The initial messages to associate with the new thread. + * @param toolResources A set of resources that are made available to the agent's tools in this thread. The + * resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a single thread associated with an agent on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createThread(List messages, ToolResources toolResources, + Map metadata) { + // Generated convenience method for createThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateThreadRequest createThreadRequestObj + = new CreateThreadRequest().setMessages(messages).setToolResources(toolResources).setMetadata(metadata); + BinaryData createThreadRequest = BinaryData.fromObject(createThreadRequestObj); + return createThreadWithResponse(createThreadRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgentThread.class)); + } + + /** + * Creates a new thread. Threads contain messages and can be run by agents. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a single thread associated with an agent on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createThread() { + // Generated convenience method for createThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateThreadRequest createThreadRequestObj = new CreateThreadRequest(); + BinaryData createThreadRequest = BinaryData.fromObject(createThreadRequestObj); + return createThreadWithResponse(createThreadRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgentThread.class)); + } + + /** + * Gets a list of threads that were previously created. + * + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of threads that were previously created as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listThreads(Integer limit, ListSortOrder order, String after, + String before) { + // Generated convenience method for listThreads + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + PagedFlux pagedFluxResponse = listThreads(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux + .map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgentThread.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Gets a list of threads that were previously created. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of threads that were previously created as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listThreads() { + // Generated convenience method for listThreads + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listThreads(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux + .map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgentThread.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Gets information about an existing thread. + * + * @param threadId Identifier of the thread. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about an existing thread on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getThread(String threadId) { + // Generated convenience method for getThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getThreadWithResponse(threadId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgentThread.class)); + } + + /** + * Modifies an existing thread. + * + * @param threadId The ID of the thread to modify. + * @param toolResources A set of resources that are made available to the agent's tools in this thread. The + * resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a single thread associated with an agent on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateThread(String threadId, ToolResources toolResources, + Map metadata) { + // Generated convenience method for updateThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateThreadRequest updateThreadRequestObj + = new UpdateThreadRequest().setToolResources(toolResources).setMetadata(metadata); + BinaryData updateThreadRequest = BinaryData.fromObject(updateThreadRequestObj); + return updateThreadWithResponse(threadId, updateThreadRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgentThread.class)); + } + + /** + * Modifies an existing thread. + * + * @param threadId The ID of the thread to modify. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a single thread associated with an agent on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateThread(String threadId) { + // Generated convenience method for updateThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateThreadRequest updateThreadRequestObj = new UpdateThreadRequest(); + BinaryData updateThreadRequest = BinaryData.fromObject(updateThreadRequestObj); + return updateThreadWithResponse(threadId, updateThreadRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PersistentAgentThread.class)); + } + + /** + * Deletes an existing thread. + * + * @param threadId Identifier of the thread. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the status of a thread deletion operation on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteThread(String threadId) { + // Generated convenience method for deleteThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteThreadWithResponse(threadId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ThreadDeletionStatus.class)); + } + + /** + * Gets a list of threads that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of threads that were previously created as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listThreads(RequestOptions requestOptions) { + return this.serviceClient.listThreadsAsync(requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/ThreadsClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/ThreadsClient.java new file mode 100644 index 000000000000..899a0d80a347 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/ThreadsClient.java @@ -0,0 +1,712 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.ThreadsImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateThreadRequest; +import com.azure.ai.agents.persistent.implementation.models.UpdateThreadRequest; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadDeletionStatus; +import com.azure.ai.agents.persistent.models.ThreadMessageOptions; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import java.util.List; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class) +public final class ThreadsClient { + + @Generated + private final ThreadsImpl serviceClient; + + /** + * Initializes an instance of ThreadsClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + ThreadsClient(ThreadsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a new thread. Threads contain messages and can be run by agents. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     messages (Optional): [
+     *          (Optional){
+     *             role: String(user/assistant) (Required)
+     *             content: BinaryData (Required)
+     *             attachments (Optional): [
+     *                  (Optional){
+     *                     file_id: String (Optional)
+     *                     data_source (Optional): {
+     *                         uri: String (Required)
+     *                         type: String(uri_asset/id_asset) (Required)
+     *                     }
+     *                     tools (Required): [
+     *                         BinaryData (Required)
+     *                     ]
+     *                 }
+     *             ]
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                 (recursive schema, see above)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createThreadRequest The createThreadRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about a single thread associated with an agent along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createThreadWithResponse(BinaryData createThreadRequest, + RequestOptions requestOptions) { + return this.serviceClient.createThreadWithResponse(createThreadRequest, requestOptions); + } + + /** + * Gets information about an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about an existing thread along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getThreadWithResponse(String threadId, RequestOptions requestOptions) { + return this.serviceClient.getThreadWithResponse(threadId, requestOptions); + } + + /** + * Modifies an existing thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId The ID of the thread to modify. + * @param updateThreadRequest The updateThreadRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about a single thread associated with an agent along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateThreadWithResponse(String threadId, BinaryData updateThreadRequest, + RequestOptions requestOptions) { + return this.serviceClient.updateThreadWithResponse(threadId, updateThreadRequest, requestOptions); + } + + /** + * Deletes an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the status of a thread deletion operation along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteThreadWithResponse(String threadId, RequestOptions requestOptions) { + return this.serviceClient.deleteThreadWithResponse(threadId, requestOptions); + } + + /** + * Creates a new thread. Threads contain messages and can be run by agents. + * + * @param messages The initial messages to associate with the new thread. + * @param toolResources A set of resources that are made available to the agent's tools in this thread. The + * resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a single thread associated with an agent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PersistentAgentThread createThread(List messages, ToolResources toolResources, + Map metadata) { + // Generated convenience method for createThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateThreadRequest createThreadRequestObj + = new CreateThreadRequest().setMessages(messages).setToolResources(toolResources).setMetadata(metadata); + BinaryData createThreadRequest = BinaryData.fromObject(createThreadRequestObj); + return createThreadWithResponse(createThreadRequest, requestOptions).getValue() + .toObject(PersistentAgentThread.class); + } + + /** + * Creates a new thread. Threads contain messages and can be run by agents. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a single thread associated with an agent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PersistentAgentThread createThread() { + // Generated convenience method for createThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateThreadRequest createThreadRequestObj = new CreateThreadRequest(); + BinaryData createThreadRequest = BinaryData.fromObject(createThreadRequestObj); + return createThreadWithResponse(createThreadRequest, requestOptions).getValue() + .toObject(PersistentAgentThread.class); + } + + /** + * Gets a list of threads that were previously created. + * + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of threads that were previously created as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listThreads(Integer limit, ListSortOrder order, String after, + String before) { + // Generated convenience method for listThreads + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + return serviceClient.listThreads(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(PersistentAgentThread.class)); + } + + /** + * Gets a list of threads that were previously created. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of threads that were previously created as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listThreads() { + // Generated convenience method for listThreads + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listThreads(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(PersistentAgentThread.class)); + } + + /** + * Gets information about an existing thread. + * + * @param threadId Identifier of the thread. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about an existing thread. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PersistentAgentThread getThread(String threadId) { + // Generated convenience method for getThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getThreadWithResponse(threadId, requestOptions).getValue().toObject(PersistentAgentThread.class); + } + + /** + * Modifies an existing thread. + * + * @param threadId The ID of the thread to modify. + * @param toolResources A set of resources that are made available to the agent's tools in this thread. The + * resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a single thread associated with an agent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PersistentAgentThread updateThread(String threadId, ToolResources toolResources, + Map metadata) { + // Generated convenience method for updateThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateThreadRequest updateThreadRequestObj + = new UpdateThreadRequest().setToolResources(toolResources).setMetadata(metadata); + BinaryData updateThreadRequest = BinaryData.fromObject(updateThreadRequestObj); + return updateThreadWithResponse(threadId, updateThreadRequest, requestOptions).getValue() + .toObject(PersistentAgentThread.class); + } + + /** + * Modifies an existing thread. + * + * @param threadId The ID of the thread to modify. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a single thread associated with an agent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PersistentAgentThread updateThread(String threadId) { + // Generated convenience method for updateThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateThreadRequest updateThreadRequestObj = new UpdateThreadRequest(); + BinaryData updateThreadRequest = BinaryData.fromObject(updateThreadRequestObj); + return updateThreadWithResponse(threadId, updateThreadRequest, requestOptions).getValue() + .toObject(PersistentAgentThread.class); + } + + /** + * Deletes an existing thread. + * + * @param threadId Identifier of the thread. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the status of a thread deletion operation. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ThreadDeletionStatus deleteThread(String threadId) { + // Generated convenience method for deleteThreadWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteThreadWithResponse(threadId, requestOptions).getValue().toObject(ThreadDeletionStatus.class); + } + + /** + * Gets a list of threads that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of threads that were previously created as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listThreads(RequestOptions requestOptions) { + return this.serviceClient.listThreads(requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesAsyncClient.java new file mode 100644 index 000000000000..4a7462278bcb --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesAsyncClient.java @@ -0,0 +1,448 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.VectorStoreFileBatchesImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateVectorStoreFileBatchRequest; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequest; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.ai.agents.persistent.models.VectorStoreFile; +import com.azure.ai.agents.persistent.models.VectorStoreFileBatch; +import com.azure.ai.agents.persistent.models.VectorStoreFileStatusFilter; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class, isAsync = true) +public final class VectorStoreFileBatchesAsyncClient { + + @Generated + private final VectorStoreFileBatchesImpl serviceClient; + + /** + * Initializes an instance of VectorStoreFileBatchesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VectorStoreFileBatchesAsyncClient(VectorStoreFileBatchesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Create a vector store file batch. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_ids (Optional): [
+     *         String (Optional)
+     *     ]
+     *     data_sources (Optional): [
+     *          (Optional){
+     *             uri: String (Required)
+     *             type: String(uri_asset/id_asset) (Required)
+     *         }
+     *     ]
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param createVectorStoreFileBatchRequest The createVectorStoreFileBatchRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createVectorStoreFileBatchWithResponse(String vectorStoreId, + BinaryData createVectorStoreFileBatchRequest, RequestOptions requestOptions) { + return this.serviceClient.createVectorStoreFileBatchWithResponseAsync(vectorStoreId, + createVectorStoreFileBatchRequest, requestOptions); + } + + /** + * Retrieve a vector store file batch. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getVectorStoreFileBatchWithResponse(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + return this.serviceClient.getVectorStoreFileBatchWithResponseAsync(vectorStoreId, batchId, requestOptions); + } + + /** + * Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as + * possible. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> cancelVectorStoreFileBatchWithResponse(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + return this.serviceClient.cancelVectorStoreFileBatchWithResponseAsync(vectorStoreId, batchId, requestOptions); + } + + /** + * Create a vector store file batch. + * + * @param vectorStoreId Identifier of the vector store. + * @param fileIds List of file identifiers. + * @param dataSources List of Azure assets. + * @param chunkingStrategy The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a batch of files attached to a vector store on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createVectorStoreFileBatch(String vectorStoreId, List fileIds, + List dataSources, VectorStoreChunkingStrategyRequest chunkingStrategy) { + // Generated convenience method for createVectorStoreFileBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequestObj + = new CreateVectorStoreFileBatchRequest().setFileIds(fileIds) + .setDataSources(dataSources) + .setChunkingStrategy(chunkingStrategy); + BinaryData createVectorStoreFileBatchRequest = BinaryData.fromObject(createVectorStoreFileBatchRequestObj); + return createVectorStoreFileBatchWithResponse(vectorStoreId, createVectorStoreFileBatchRequest, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFileBatch.class)); + } + + /** + * Create a vector store file batch. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a batch of files attached to a vector store on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createVectorStoreFileBatch(String vectorStoreId) { + // Generated convenience method for createVectorStoreFileBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequestObj + = new CreateVectorStoreFileBatchRequest(); + BinaryData createVectorStoreFileBatchRequest = BinaryData.fromObject(createVectorStoreFileBatchRequestObj); + return createVectorStoreFileBatchWithResponse(vectorStoreId, createVectorStoreFileBatchRequest, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFileBatch.class)); + } + + /** + * Retrieve a vector store file batch. + * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a batch of files attached to a vector store on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getVectorStoreFileBatch(String vectorStoreId, String batchId) { + // Generated convenience method for getVectorStoreFileBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getVectorStoreFileBatchWithResponse(vectorStoreId, batchId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFileBatch.class)); + } + + /** + * Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as + * possible. + * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a batch of files attached to a vector store on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono cancelVectorStoreFileBatch(String vectorStoreId, String batchId) { + // Generated convenience method for cancelVectorStoreFileBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return cancelVectorStoreFileBatchWithResponse(vectorStoreId, batchId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFileBatch.class)); + } + + /** + * Returns a list of vector store files in a batch. + * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param filter Filter by file status. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStoreFileBatchFiles(String vectorStoreId, String batchId, + VectorStoreFileStatusFilter filter, Integer limit, ListSortOrder order, String after, String before) { + // Generated convenience method for listVectorStoreFileBatchFiles + RequestOptions requestOptions = new RequestOptions(); + if (filter != null) { + requestOptions.addQueryParam("filter", filter.toString(), false); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + PagedFlux pagedFluxResponse = listVectorStoreFileBatchFiles(vectorStoreId, batchId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFile.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Returns a list of vector store files in a batch. + * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStoreFileBatchFiles(String vectorStoreId, String batchId) { + // Generated convenience method for listVectorStoreFileBatchFiles + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listVectorStoreFileBatchFiles(vectorStoreId, batchId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFile.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Returns a list of vector store files in a batch. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStoreFileBatchFiles(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + return this.serviceClient.listVectorStoreFileBatchFilesAsync(vectorStoreId, batchId, requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesClient.java new file mode 100644 index 000000000000..e65e07cba63d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesClient.java @@ -0,0 +1,417 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.VectorStoreFileBatchesImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateVectorStoreFileBatchRequest; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequest; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.ai.agents.persistent.models.VectorStoreFile; +import com.azure.ai.agents.persistent.models.VectorStoreFileBatch; +import com.azure.ai.agents.persistent.models.VectorStoreFileStatusFilter; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import java.util.List; + +/** + * Initializes a new instance of the synchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class) +public final class VectorStoreFileBatchesClient { + + @Generated + private final VectorStoreFileBatchesImpl serviceClient; + + /** + * Initializes an instance of VectorStoreFileBatchesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VectorStoreFileBatchesClient(VectorStoreFileBatchesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Create a vector store file batch. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_ids (Optional): [
+     *         String (Optional)
+     *     ]
+     *     data_sources (Optional): [
+     *          (Optional){
+     *             uri: String (Required)
+     *             type: String(uri_asset/id_asset) (Required)
+     *         }
+     *     ]
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param createVectorStoreFileBatchRequest The createVectorStoreFileBatchRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createVectorStoreFileBatchWithResponse(String vectorStoreId, + BinaryData createVectorStoreFileBatchRequest, RequestOptions requestOptions) { + return this.serviceClient.createVectorStoreFileBatchWithResponse(vectorStoreId, + createVectorStoreFileBatchRequest, requestOptions); + } + + /** + * Retrieve a vector store file batch. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getVectorStoreFileBatchWithResponse(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + return this.serviceClient.getVectorStoreFileBatchWithResponse(vectorStoreId, batchId, requestOptions); + } + + /** + * Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as + * possible. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response cancelVectorStoreFileBatchWithResponse(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + return this.serviceClient.cancelVectorStoreFileBatchWithResponse(vectorStoreId, batchId, requestOptions); + } + + /** + * Create a vector store file batch. + * + * @param vectorStoreId Identifier of the vector store. + * @param fileIds List of file identifiers. + * @param dataSources List of Azure assets. + * @param chunkingStrategy The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a batch of files attached to a vector store. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStoreFileBatch createVectorStoreFileBatch(String vectorStoreId, List fileIds, + List dataSources, VectorStoreChunkingStrategyRequest chunkingStrategy) { + // Generated convenience method for createVectorStoreFileBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequestObj + = new CreateVectorStoreFileBatchRequest().setFileIds(fileIds) + .setDataSources(dataSources) + .setChunkingStrategy(chunkingStrategy); + BinaryData createVectorStoreFileBatchRequest = BinaryData.fromObject(createVectorStoreFileBatchRequestObj); + return createVectorStoreFileBatchWithResponse(vectorStoreId, createVectorStoreFileBatchRequest, requestOptions) + .getValue() + .toObject(VectorStoreFileBatch.class); + } + + /** + * Create a vector store file batch. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a batch of files attached to a vector store. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStoreFileBatch createVectorStoreFileBatch(String vectorStoreId) { + // Generated convenience method for createVectorStoreFileBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequestObj + = new CreateVectorStoreFileBatchRequest(); + BinaryData createVectorStoreFileBatchRequest = BinaryData.fromObject(createVectorStoreFileBatchRequestObj); + return createVectorStoreFileBatchWithResponse(vectorStoreId, createVectorStoreFileBatchRequest, requestOptions) + .getValue() + .toObject(VectorStoreFileBatch.class); + } + + /** + * Retrieve a vector store file batch. + * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a batch of files attached to a vector store. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStoreFileBatch getVectorStoreFileBatch(String vectorStoreId, String batchId) { + // Generated convenience method for getVectorStoreFileBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getVectorStoreFileBatchWithResponse(vectorStoreId, batchId, requestOptions).getValue() + .toObject(VectorStoreFileBatch.class); + } + + /** + * Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as + * possible. + * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a batch of files attached to a vector store. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStoreFileBatch cancelVectorStoreFileBatch(String vectorStoreId, String batchId) { + // Generated convenience method for cancelVectorStoreFileBatchWithResponse + RequestOptions requestOptions = new RequestOptions(); + return cancelVectorStoreFileBatchWithResponse(vectorStoreId, batchId, requestOptions).getValue() + .toObject(VectorStoreFileBatch.class); + } + + /** + * Returns a list of vector store files in a batch. + * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param filter Filter by file status. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStoreFileBatchFiles(String vectorStoreId, String batchId, + VectorStoreFileStatusFilter filter, Integer limit, ListSortOrder order, String after, String before) { + // Generated convenience method for listVectorStoreFileBatchFiles + RequestOptions requestOptions = new RequestOptions(); + if (filter != null) { + requestOptions.addQueryParam("filter", filter.toString(), false); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + return serviceClient.listVectorStoreFileBatchFiles(vectorStoreId, batchId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(VectorStoreFile.class)); + } + + /** + * Returns a list of vector store files in a batch. + * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStoreFileBatchFiles(String vectorStoreId, String batchId) { + // Generated convenience method for listVectorStoreFileBatchFiles + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listVectorStoreFileBatchFiles(vectorStoreId, batchId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(VectorStoreFile.class)); + } + + /** + * Returns a list of vector store files in a batch. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStoreFileBatchFiles(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + return this.serviceClient.listVectorStoreFileBatchFiles(vectorStoreId, batchId, requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFilesAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFilesAsyncClient.java new file mode 100644 index 000000000000..da366cbf9140 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFilesAsyncClient.java @@ -0,0 +1,429 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.VectorStoreFilesImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateVectorStoreFileRequest; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequest; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.ai.agents.persistent.models.VectorStoreFile; +import com.azure.ai.agents.persistent.models.VectorStoreFileDeletionStatus; +import com.azure.ai.agents.persistent.models.VectorStoreFileStatusFilter; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class, isAsync = true) +public final class VectorStoreFilesAsyncClient { + + @Generated + private final VectorStoreFilesImpl serviceClient; + + /** + * Initializes an instance of VectorStoreFilesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VectorStoreFilesAsyncClient(VectorStoreFilesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Create a vector store file by attaching a file to a vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_id: String (Optional)
+     *     data_source (Optional): {
+     *         uri: String (Required)
+     *         type: String(uri_asset/id_asset) (Required)
+     *     }
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param createVectorStoreFileRequest The createVectorStoreFileRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return description of a file attached to a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createVectorStoreFileWithResponse(String vectorStoreId, + BinaryData createVectorStoreFileRequest, RequestOptions requestOptions) { + return this.serviceClient.createVectorStoreFileWithResponseAsync(vectorStoreId, createVectorStoreFileRequest, + requestOptions); + } + + /** + * Retrieves a vector store file. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return description of a file attached to a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getVectorStoreFileWithResponse(String vectorStoreId, String fileId, + RequestOptions requestOptions) { + return this.serviceClient.getVectorStoreFileWithResponseAsync(vectorStoreId, fileId, requestOptions); + } + + /** + * Deletes a vector store file. This removes the file‐to‐store link (does not delete the file itself). + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return response object for deleting a vector store file relationship along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteVectorStoreFileWithResponse(String vectorStoreId, String fileId, + RequestOptions requestOptions) { + return this.serviceClient.deleteVectorStoreFileWithResponseAsync(vectorStoreId, fileId, requestOptions); + } + + /** + * Returns a list of vector store files. + * + * @param vectorStoreId Identifier of the vector store. + * @param filter Filter by file status. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStoreFiles(String vectorStoreId, VectorStoreFileStatusFilter filter, + Integer limit, ListSortOrder order, String after, String before) { + // Generated convenience method for listVectorStoreFiles + RequestOptions requestOptions = new RequestOptions(); + if (filter != null) { + requestOptions.addQueryParam("filter", filter.toString(), false); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + PagedFlux pagedFluxResponse = listVectorStoreFiles(vectorStoreId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFile.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Returns a list of vector store files. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStoreFiles(String vectorStoreId) { + // Generated convenience method for listVectorStoreFiles + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listVectorStoreFiles(vectorStoreId, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFile.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Create a vector store file by attaching a file to a vector store. + * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @param dataSource Azure asset ID. + * @param chunkingStrategy The chunking strategy used to chunk the file. If not set, uses the auto strategy. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return description of a file attached to a vector store on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createVectorStoreFile(String vectorStoreId, String fileId, + VectorStoreDataSource dataSource, VectorStoreChunkingStrategyRequest chunkingStrategy) { + // Generated convenience method for createVectorStoreFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreFileRequest createVectorStoreFileRequestObj + = new CreateVectorStoreFileRequest().setFileId(fileId) + .setDataSource(dataSource) + .setChunkingStrategy(chunkingStrategy); + BinaryData createVectorStoreFileRequest = BinaryData.fromObject(createVectorStoreFileRequestObj); + return createVectorStoreFileWithResponse(vectorStoreId, createVectorStoreFileRequest, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFile.class)); + } + + /** + * Create a vector store file by attaching a file to a vector store. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return description of a file attached to a vector store on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createVectorStoreFile(String vectorStoreId) { + // Generated convenience method for createVectorStoreFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreFileRequest createVectorStoreFileRequestObj = new CreateVectorStoreFileRequest(); + BinaryData createVectorStoreFileRequest = BinaryData.fromObject(createVectorStoreFileRequestObj); + return createVectorStoreFileWithResponse(vectorStoreId, createVectorStoreFileRequest, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFile.class)); + } + + /** + * Retrieves a vector store file. + * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return description of a file attached to a vector store on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getVectorStoreFile(String vectorStoreId, String fileId) { + // Generated convenience method for getVectorStoreFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getVectorStoreFileWithResponse(vectorStoreId, fileId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFile.class)); + } + + /** + * Deletes a vector store file. This removes the file‐to‐store link (does not delete the file itself). + * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response object for deleting a vector store file relationship on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteVectorStoreFile(String vectorStoreId, String fileId) { + // Generated convenience method for deleteVectorStoreFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteVectorStoreFileWithResponse(vectorStoreId, fileId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreFileDeletionStatus.class)); + } + + /** + * Returns a list of vector store files. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStoreFiles(String vectorStoreId, RequestOptions requestOptions) { + return this.serviceClient.listVectorStoreFilesAsync(vectorStoreId, requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFilesClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFilesClient.java new file mode 100644 index 000000000000..cf1d4549688c --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoreFilesClient.java @@ -0,0 +1,396 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.VectorStoreFilesImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateVectorStoreFileRequest; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequest; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.ai.agents.persistent.models.VectorStoreFile; +import com.azure.ai.agents.persistent.models.VectorStoreFileDeletionStatus; +import com.azure.ai.agents.persistent.models.VectorStoreFileStatusFilter; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; + +/** + * Initializes a new instance of the synchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class) +public final class VectorStoreFilesClient { + + @Generated + private final VectorStoreFilesImpl serviceClient; + + /** + * Initializes an instance of VectorStoreFilesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VectorStoreFilesClient(VectorStoreFilesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Create a vector store file by attaching a file to a vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_id: String (Optional)
+     *     data_source (Optional): {
+     *         uri: String (Required)
+     *         type: String(uri_asset/id_asset) (Required)
+     *     }
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param createVectorStoreFileRequest The createVectorStoreFileRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return description of a file attached to a vector store along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createVectorStoreFileWithResponse(String vectorStoreId, + BinaryData createVectorStoreFileRequest, RequestOptions requestOptions) { + return this.serviceClient.createVectorStoreFileWithResponse(vectorStoreId, createVectorStoreFileRequest, + requestOptions); + } + + /** + * Retrieves a vector store file. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return description of a file attached to a vector store along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getVectorStoreFileWithResponse(String vectorStoreId, String fileId, + RequestOptions requestOptions) { + return this.serviceClient.getVectorStoreFileWithResponse(vectorStoreId, fileId, requestOptions); + } + + /** + * Deletes a vector store file. This removes the file‐to‐store link (does not delete the file itself). + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return response object for deleting a vector store file relationship along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteVectorStoreFileWithResponse(String vectorStoreId, String fileId, + RequestOptions requestOptions) { + return this.serviceClient.deleteVectorStoreFileWithResponse(vectorStoreId, fileId, requestOptions); + } + + /** + * Returns a list of vector store files. + * + * @param vectorStoreId Identifier of the vector store. + * @param filter Filter by file status. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStoreFiles(String vectorStoreId, VectorStoreFileStatusFilter filter, + Integer limit, ListSortOrder order, String after, String before) { + // Generated convenience method for listVectorStoreFiles + RequestOptions requestOptions = new RequestOptions(); + if (filter != null) { + requestOptions.addQueryParam("filter", filter.toString(), false); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + return serviceClient.listVectorStoreFiles(vectorStoreId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(VectorStoreFile.class)); + } + + /** + * Returns a list of vector store files. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStoreFiles(String vectorStoreId) { + // Generated convenience method for listVectorStoreFiles + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listVectorStoreFiles(vectorStoreId, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(VectorStoreFile.class)); + } + + /** + * Create a vector store file by attaching a file to a vector store. + * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @param dataSource Azure asset ID. + * @param chunkingStrategy The chunking strategy used to chunk the file. If not set, uses the auto strategy. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return description of a file attached to a vector store. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStoreFile createVectorStoreFile(String vectorStoreId, String fileId, VectorStoreDataSource dataSource, + VectorStoreChunkingStrategyRequest chunkingStrategy) { + // Generated convenience method for createVectorStoreFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreFileRequest createVectorStoreFileRequestObj + = new CreateVectorStoreFileRequest().setFileId(fileId) + .setDataSource(dataSource) + .setChunkingStrategy(chunkingStrategy); + BinaryData createVectorStoreFileRequest = BinaryData.fromObject(createVectorStoreFileRequestObj); + return createVectorStoreFileWithResponse(vectorStoreId, createVectorStoreFileRequest, requestOptions).getValue() + .toObject(VectorStoreFile.class); + } + + /** + * Create a vector store file by attaching a file to a vector store. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return description of a file attached to a vector store. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStoreFile createVectorStoreFile(String vectorStoreId) { + // Generated convenience method for createVectorStoreFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreFileRequest createVectorStoreFileRequestObj = new CreateVectorStoreFileRequest(); + BinaryData createVectorStoreFileRequest = BinaryData.fromObject(createVectorStoreFileRequestObj); + return createVectorStoreFileWithResponse(vectorStoreId, createVectorStoreFileRequest, requestOptions).getValue() + .toObject(VectorStoreFile.class); + } + + /** + * Retrieves a vector store file. + * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return description of a file attached to a vector store. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStoreFile getVectorStoreFile(String vectorStoreId, String fileId) { + // Generated convenience method for getVectorStoreFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getVectorStoreFileWithResponse(vectorStoreId, fileId, requestOptions).getValue() + .toObject(VectorStoreFile.class); + } + + /** + * Deletes a vector store file. This removes the file‐to‐store link (does not delete the file itself). + * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response object for deleting a vector store file relationship. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStoreFileDeletionStatus deleteVectorStoreFile(String vectorStoreId, String fileId) { + // Generated convenience method for deleteVectorStoreFileWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteVectorStoreFileWithResponse(vectorStoreId, fileId, requestOptions).getValue() + .toObject(VectorStoreFileDeletionStatus.class); + } + + /** + * Returns a list of vector store files. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStoreFiles(String vectorStoreId, RequestOptions requestOptions) { + return this.serviceClient.listVectorStoreFiles(vectorStoreId, requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoresAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoresAsyncClient.java new file mode 100644 index 000000000000..d0bc1723c269 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoresAsyncClient.java @@ -0,0 +1,589 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.VectorStoresImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateVectorStoreRequest; +import com.azure.ai.agents.persistent.implementation.models.ModifyVectorStoreRequest; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequest; +import com.azure.ai.agents.persistent.models.VectorStoreConfiguration; +import com.azure.ai.agents.persistent.models.VectorStoreDeletionStatus; +import com.azure.ai.agents.persistent.models.VectorStoreExpirationPolicy; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class, isAsync = true) +public final class VectorStoresAsyncClient { + + @Generated + private final VectorStoresImpl serviceClient; + + /** + * Initializes an instance of VectorStoresAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VectorStoresAsyncClient(VectorStoresImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_ids (Optional): [
+     *         String (Optional)
+     *     ]
+     *     name: String (Optional)
+     *     configuration (Optional): {
+     *         data_sources (Required): [
+     *              (Required){
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *         ]
+     *     }
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createVectorStoreRequest The createVectorStoreRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createVectorStoreWithResponse(BinaryData createVectorStoreRequest, + RequestOptions requestOptions) { + return this.serviceClient.createVectorStoreWithResponseAsync(createVectorStoreRequest, requestOptions); + } + + /** + * Returns the vector store object matching the specified ID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getVectorStoreWithResponse(String vectorStoreId, RequestOptions requestOptions) { + return this.serviceClient.getVectorStoreWithResponseAsync(vectorStoreId, requestOptions); + } + + /** + * Modifies an existing vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Optional)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param modifyVectorStoreRequest The modifyVectorStoreRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> modifyVectorStoreWithResponse(String vectorStoreId, + BinaryData modifyVectorStoreRequest, RequestOptions requestOptions) { + return this.serviceClient.modifyVectorStoreWithResponseAsync(vectorStoreId, modifyVectorStoreRequest, + requestOptions); + } + + /** + * Deletes the vector store object matching the specified ID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return response object for deleting a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteVectorStoreWithResponse(String vectorStoreId, + RequestOptions requestOptions) { + return this.serviceClient.deleteVectorStoreWithResponseAsync(vectorStoreId, requestOptions); + } + + /** + * Returns a list of vector stores. + * + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStores(Integer limit, ListSortOrder order, String after, String before) { + // Generated convenience method for listVectorStores + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + PagedFlux pagedFluxResponse = listVectorStores(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(VectorStore.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Returns a list of vector stores. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStores() { + // Generated convenience method for listVectorStores + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listVectorStores(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux> flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase(pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(VectorStore.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Creates a vector store. + * + * @param fileIds A list of file IDs that the vector store should use. Useful for tools like `file_search` that can + * access files. + * @param name The name of the vector store. + * @param storeConfiguration The vector store configuration, used when vector store is created from Azure asset + * URIs. + * @param expiresAfter Details on when this vector store expires. + * @param chunkingStrategy The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + * Only applicable if file_ids is non-empty. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a vector store is a collection of processed files can be used by the `file_search` tool on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createVectorStore(List fileIds, String name, + VectorStoreConfiguration storeConfiguration, VectorStoreExpirationPolicy expiresAfter, + VectorStoreChunkingStrategyRequest chunkingStrategy, Map metadata) { + // Generated convenience method for createVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreRequest createVectorStoreRequestObj = new CreateVectorStoreRequest().setFileIds(fileIds) + .setName(name) + .setStoreConfiguration(storeConfiguration) + .setExpiresAfter(expiresAfter) + .setChunkingStrategy(chunkingStrategy) + .setMetadata(metadata); + BinaryData createVectorStoreRequest = BinaryData.fromObject(createVectorStoreRequestObj); + return createVectorStoreWithResponse(createVectorStoreRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStore.class)); + } + + /** + * Creates a vector store. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a vector store is a collection of processed files can be used by the `file_search` tool on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createVectorStore() { + // Generated convenience method for createVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreRequest createVectorStoreRequestObj = new CreateVectorStoreRequest(); + BinaryData createVectorStoreRequest = BinaryData.fromObject(createVectorStoreRequestObj); + return createVectorStoreWithResponse(createVectorStoreRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStore.class)); + } + + /** + * Returns the vector store object matching the specified ID. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a vector store is a collection of processed files can be used by the `file_search` tool on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getVectorStore(String vectorStoreId) { + // Generated convenience method for getVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getVectorStoreWithResponse(vectorStoreId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStore.class)); + } + + /** + * Modifies an existing vector store. + * + * @param vectorStoreId Identifier of the vector store. + * @param name The name of the vector store. + * @param expiresAfter Details on when this vector store expires. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a vector store is a collection of processed files can be used by the `file_search` tool on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono modifyVectorStore(String vectorStoreId, String name, + VectorStoreExpirationPolicy expiresAfter, Map metadata) { + // Generated convenience method for modifyVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + ModifyVectorStoreRequest modifyVectorStoreRequestObj + = new ModifyVectorStoreRequest().setName(name).setExpiresAfter(expiresAfter).setMetadata(metadata); + BinaryData modifyVectorStoreRequest = BinaryData.fromObject(modifyVectorStoreRequestObj); + return modifyVectorStoreWithResponse(vectorStoreId, modifyVectorStoreRequest, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStore.class)); + } + + /** + * Modifies an existing vector store. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a vector store is a collection of processed files can be used by the `file_search` tool on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono modifyVectorStore(String vectorStoreId) { + // Generated convenience method for modifyVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + ModifyVectorStoreRequest modifyVectorStoreRequestObj = new ModifyVectorStoreRequest(); + BinaryData modifyVectorStoreRequest = BinaryData.fromObject(modifyVectorStoreRequestObj); + return modifyVectorStoreWithResponse(vectorStoreId, modifyVectorStoreRequest, requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStore.class)); + } + + /** + * Deletes the vector store object matching the specified ID. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response object for deleting a vector store on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteVectorStore(String vectorStoreId) { + // Generated convenience method for deleteVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteVectorStoreWithResponse(vectorStoreId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(VectorStoreDeletionStatus.class)); + } + + /** + * Returns a list of vector stores. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStores(RequestOptions requestOptions) { + return this.serviceClient.listVectorStoresAsync(requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoresClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoresClient.java new file mode 100644 index 000000000000..46a64ea86c13 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/VectorStoresClient.java @@ -0,0 +1,552 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.VectorStoresImpl; +import com.azure.ai.agents.persistent.implementation.models.CreateVectorStoreRequest; +import com.azure.ai.agents.persistent.implementation.models.ModifyVectorStoreRequest; +import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequest; +import com.azure.ai.agents.persistent.models.VectorStoreConfiguration; +import com.azure.ai.agents.persistent.models.VectorStoreDeletionStatus; +import com.azure.ai.agents.persistent.models.VectorStoreExpirationPolicy; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import java.util.List; +import java.util.Map; + +/** + * Initializes a new instance of the synchronous PersistentAgentsAdministrationClient type. + */ +@ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class) +public final class VectorStoresClient { + + @Generated + private final VectorStoresImpl serviceClient; + + /** + * Initializes an instance of VectorStoresClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + VectorStoresClient(VectorStoresImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Creates a vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_ids (Optional): [
+     *         String (Optional)
+     *     ]
+     *     name: String (Optional)
+     *     configuration (Optional): {
+     *         data_sources (Required): [
+     *              (Required){
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *         ]
+     *     }
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createVectorStoreRequest The createVectorStoreRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createVectorStoreWithResponse(BinaryData createVectorStoreRequest, + RequestOptions requestOptions) { + return this.serviceClient.createVectorStoreWithResponse(createVectorStoreRequest, requestOptions); + } + + /** + * Returns the vector store object matching the specified ID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getVectorStoreWithResponse(String vectorStoreId, RequestOptions requestOptions) { + return this.serviceClient.getVectorStoreWithResponse(vectorStoreId, requestOptions); + } + + /** + * Modifies an existing vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Optional)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param modifyVectorStoreRequest The modifyVectorStoreRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response modifyVectorStoreWithResponse(String vectorStoreId, BinaryData modifyVectorStoreRequest, + RequestOptions requestOptions) { + return this.serviceClient.modifyVectorStoreWithResponse(vectorStoreId, modifyVectorStoreRequest, + requestOptions); + } + + /** + * Deletes the vector store object matching the specified ID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return response object for deleting a vector store along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteVectorStoreWithResponse(String vectorStoreId, RequestOptions requestOptions) { + return this.serviceClient.deleteVectorStoreWithResponse(vectorStoreId, requestOptions); + } + + /** + * Returns a list of vector stores. + * + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default + * is 20. + * @param order Sort order by the created_at timestamp of the objects. asc for ascending order and desc for + * descending order. + * @param after 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. + * @param before 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStores(Integer limit, ListSortOrder order, String after, + String before) { + // Generated convenience method for listVectorStores + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + return serviceClient.listVectorStores(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(VectorStore.class)); + } + + /** + * Returns a list of vector stores. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStores() { + // Generated convenience method for listVectorStores + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listVectorStores(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(VectorStore.class)); + } + + /** + * Creates a vector store. + * + * @param fileIds A list of file IDs that the vector store should use. Useful for tools like `file_search` that can + * access files. + * @param name The name of the vector store. + * @param storeConfiguration The vector store configuration, used when vector store is created from Azure asset + * URIs. + * @param expiresAfter Details on when this vector store expires. + * @param chunkingStrategy The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + * Only applicable if file_ids is non-empty. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a vector store is a collection of processed files can be used by the `file_search` tool. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStore createVectorStore(List fileIds, String name, VectorStoreConfiguration storeConfiguration, + VectorStoreExpirationPolicy expiresAfter, VectorStoreChunkingStrategyRequest chunkingStrategy, + Map metadata) { + // Generated convenience method for createVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreRequest createVectorStoreRequestObj = new CreateVectorStoreRequest().setFileIds(fileIds) + .setName(name) + .setStoreConfiguration(storeConfiguration) + .setExpiresAfter(expiresAfter) + .setChunkingStrategy(chunkingStrategy) + .setMetadata(metadata); + BinaryData createVectorStoreRequest = BinaryData.fromObject(createVectorStoreRequestObj); + return createVectorStoreWithResponse(createVectorStoreRequest, requestOptions).getValue() + .toObject(VectorStore.class); + } + + /** + * Creates a vector store. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a vector store is a collection of processed files can be used by the `file_search` tool. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStore createVectorStore() { + // Generated convenience method for createVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateVectorStoreRequest createVectorStoreRequestObj = new CreateVectorStoreRequest(); + BinaryData createVectorStoreRequest = BinaryData.fromObject(createVectorStoreRequestObj); + return createVectorStoreWithResponse(createVectorStoreRequest, requestOptions).getValue() + .toObject(VectorStore.class); + } + + /** + * Returns the vector store object matching the specified ID. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a vector store is a collection of processed files can be used by the `file_search` tool. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStore getVectorStore(String vectorStoreId) { + // Generated convenience method for getVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getVectorStoreWithResponse(vectorStoreId, requestOptions).getValue().toObject(VectorStore.class); + } + + /** + * Modifies an existing vector store. + * + * @param vectorStoreId Identifier of the vector store. + * @param name The name of the vector store. + * @param expiresAfter Details on when this vector store expires. + * @param metadata 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a vector store is a collection of processed files can be used by the `file_search` tool. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStore modifyVectorStore(String vectorStoreId, String name, VectorStoreExpirationPolicy expiresAfter, + Map metadata) { + // Generated convenience method for modifyVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + ModifyVectorStoreRequest modifyVectorStoreRequestObj + = new ModifyVectorStoreRequest().setName(name).setExpiresAfter(expiresAfter).setMetadata(metadata); + BinaryData modifyVectorStoreRequest = BinaryData.fromObject(modifyVectorStoreRequestObj); + return modifyVectorStoreWithResponse(vectorStoreId, modifyVectorStoreRequest, requestOptions).getValue() + .toObject(VectorStore.class); + } + + /** + * Modifies an existing vector store. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a vector store is a collection of processed files can be used by the `file_search` tool. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStore modifyVectorStore(String vectorStoreId) { + // Generated convenience method for modifyVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + ModifyVectorStoreRequest modifyVectorStoreRequestObj = new ModifyVectorStoreRequest(); + BinaryData modifyVectorStoreRequest = BinaryData.fromObject(modifyVectorStoreRequestObj); + return modifyVectorStoreWithResponse(vectorStoreId, modifyVectorStoreRequest, requestOptions).getValue() + .toObject(VectorStore.class); + } + + /** + * Deletes the vector store object matching the specified ID. + * + * @param vectorStoreId Identifier of the vector store. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response object for deleting a vector store. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public VectorStoreDeletionStatus deleteVectorStore(String vectorStoreId) { + // Generated convenience method for deleteVectorStoreWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteVectorStoreWithResponse(vectorStoreId, requestOptions).getValue() + .toObject(VectorStoreDeletionStatus.class); + } + + /** + * Returns a list of vector stores. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStores(RequestOptions requestOptions) { + return this.serviceClient.listVectorStores(requestOptions); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/FilesImpl.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/FilesImpl.java new file mode 100644 index 000000000000..9e8c8cdbfd46 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/FilesImpl.java @@ -0,0 +1,519 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent.implementation; + +import com.azure.ai.agents.persistent.AgentsServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Files. + */ +public final class FilesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FilesService service; + + /** + * The service client containing this operation class. + */ + private final PersistentAgentsAdministrationClientImpl client; + + /** + * Initializes an instance of FilesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FilesImpl(PersistentAgentsAdministrationClientImpl client) { + this.service = RestProxy.create(FilesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AgentsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PersistentAgentsAdministrationClientFiles to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PersistentAgentsAdmi") + public interface FilesService { + @Get("/files") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listFiles(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/files") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listFilesSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/files") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadFile(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("content-type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/files") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadFileSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("content-type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + @Delete("/files/{fileId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteFile(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("fileId") String fileId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/files/{fileId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteFileSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("fileId") String fileId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/files/{fileId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getFile(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("fileId") String fileId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/files/{fileId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getFileSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("fileId") String fileId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/files/{fileId}/content") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getFileContent(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("fileId") String fileId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/files/{fileId}/content") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getFileContentSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("fileId") String fileId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Gets a list of previously uploaded files. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
purposeStringNoThe purpose of the file. Allowed values: "fine-tune", + * "fine-tune-results", "assistants", "assistants_output", "batch", "batch_output", "vision".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     data (Required): [
+     *          (Required){
+     *             object: String (Required)
+     *             id: String (Required)
+     *             bytes: int (Required)
+     *             filename: String (Required)
+     *             created_at: long (Required)
+     *             purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *             status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *             status_details: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of previously uploaded files along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listFilesWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listFiles(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)); + } + + /** + * Gets a list of previously uploaded files. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
purposeStringNoThe purpose of the file. Allowed values: "fine-tune", + * "fine-tune-results", "assistants", "assistants_output", "batch", "batch_output", "vision".
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     data (Required): [
+     *          (Required){
+     *             object: String (Required)
+     *             id: String (Required)
+     *             bytes: int (Required)
+     *             filename: String (Required)
+     *             created_at: long (Required)
+     *             purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *             status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *             status_details: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of previously uploaded files along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response listFilesWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.listFilesSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), accept, + requestOptions, Context.NONE); + } + + /** + * Uploads a file for use by other operations. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     id: String (Required)
+     *     bytes: int (Required)
+     *     filename: String (Required)
+     *     created_at: long (Required)
+     *     purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *     status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *     status_details: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body Multipart body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> uploadFileWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.uploadFile(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); + } + + /** + * Uploads a file for use by other operations. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     id: String (Required)
+     *     bytes: int (Required)
+     *     filename: String (Required)
+     *     created_at: long (Required)
+     *     purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *     status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *     status_details: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body Multipart body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response uploadFileWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + final String accept = "application/json"; + return service.uploadFileSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + contentType, accept, body, requestOptions, Context.NONE); + } + + /** + * Delete a previously uploaded file. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param fileId The ID of the file to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a status response from a file deletion operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteFileWithResponseAsync(String fileId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteFile(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), fileId, accept, requestOptions, context)); + } + + /** + * Delete a previously uploaded file. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param fileId The ID of the file to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a status response from a file deletion operation along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteFileWithResponse(String fileId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteFileSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), fileId, + accept, requestOptions, Context.NONE); + } + + /** + * Returns information about a specific file. Does not retrieve file content. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     id: String (Required)
+     *     bytes: int (Required)
+     *     filename: String (Required)
+     *     created_at: long (Required)
+     *     purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *     status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *     status_details: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param fileId The ID of the file to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFileWithResponseAsync(String fileId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getFile(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), fileId, accept, requestOptions, context)); + } + + /** + * Returns information about a specific file. Does not retrieve file content. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     object: String (Required)
+     *     id: String (Required)
+     *     bytes: int (Required)
+     *     filename: String (Required)
+     *     created_at: long (Required)
+     *     purpose: String(fine-tune/fine-tune-results/assistants/assistants_output/batch/batch_output/vision) (Required)
+     *     status: String(uploaded/pending/running/processed/error/deleting/deleted) (Optional)
+     *     status_details: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param fileId The ID of the file to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFileWithResponse(String fileId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getFileSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), fileId, + accept, requestOptions, Context.NONE); + } + + /** + * Retrieves the raw content of a specific file. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param fileId The ID of the file to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getFileContentWithResponseAsync(String fileId, RequestOptions requestOptions) { + final String accept = "application/octet-stream"; + return FluxUtil.withContext(context -> service.getFileContent(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), fileId, accept, requestOptions, context)); + } + + /** + * Retrieves the raw content of a specific file. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param fileId The ID of the file to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getFileContentWithResponse(String fileId, RequestOptions requestOptions) { + final String accept = "application/octet-stream"; + return service.getFileContentSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + fileId, accept, requestOptions, Context.NONE); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/MessagesImpl.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/MessagesImpl.java new file mode 100644 index 000000000000..8320ae896db6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/MessagesImpl.java @@ -0,0 +1,953 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent.implementation; + +import com.azure.ai.agents.persistent.AgentsServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Messages. + */ +public final class MessagesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MessagesService service; + + /** + * The service client containing this operation class. + */ + private final PersistentAgentsAdministrationClientImpl client; + + /** + * Initializes an instance of MessagesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + MessagesImpl(PersistentAgentsAdministrationClientImpl client) { + this.service = RestProxy.create(MessagesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AgentsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PersistentAgentsAdministrationClientMessages to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PersistentAgentsAdmi") + public interface MessagesService { + @Post("/threads/{threadId}/messages") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createMessage(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData createMessageRequest, RequestOptions requestOptions, + Context context); + + @Post("/threads/{threadId}/messages") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createMessageSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData createMessageRequest, RequestOptions requestOptions, + Context context); + + @Get("/threads/{threadId}/messages") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listMessages(@HostParam("endpoint") String endpoint, + @PathParam("threadId") String threadId, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}/messages") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listMessagesSync(@HostParam("endpoint") String endpoint, + @PathParam("threadId") String threadId, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}/messages/{messageId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getMessage(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("messageId") String messageId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}/messages/{messageId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getMessageSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("messageId") String messageId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/threads/{threadId}/messages/{messageId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> updateMessage(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("messageId") String messageId, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData updateMessageRequest, + RequestOptions requestOptions, Context context); + + @Post("/threads/{threadId}/messages/{messageId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateMessageSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("messageId") String messageId, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData updateMessageRequest, + RequestOptions requestOptions, Context context); + } + + /** + * Creates a new message on a specified thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     role: String(user/assistant) (Required)
+     *     content: BinaryData (Required)
+     *     attachments (Optional): [
+     *          (Optional){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param createMessageRequest The createMessageRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createMessageWithResponseAsync(String threadId, BinaryData createMessageRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createMessage(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + threadId, contentType, accept, createMessageRequest, requestOptions, context)); + } + + /** + * Creates a new message on a specified thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     role: String(user/assistant) (Required)
+     *     content: BinaryData (Required)
+     *     attachments (Optional): [
+     *          (Optional){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param createMessageRequest The createMessageRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createMessageWithResponse(String threadId, BinaryData createMessageRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createMessageSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + threadId, contentType, accept, createMessageRequest, requestOptions, Context.NONE); + } + + /** + * Gets a list of messages that exist on a thread. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
run_idStringNoFilter messages by the run ID that generated them.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of messages that exist on a thread along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listMessagesSinglePageAsync(String threadId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listMessages(this.client.getEndpoint(), threadId, + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null)); + } + + /** + * Gets a list of messages that exist on a thread. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
run_idStringNoFilter messages by the run ID that generated them.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of messages that exist on a thread as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listMessagesAsync(String threadId, RequestOptions requestOptions) { + return new PagedFlux<>(() -> listMessagesSinglePageAsync(threadId, requestOptions)); + } + + /** + * Gets a list of messages that exist on a thread. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
run_idStringNoFilter messages by the run ID that generated them.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of messages that exist on a thread along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listMessagesSinglePage(String threadId, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listMessagesSync(this.client.getEndpoint(), threadId, + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null); + } + + /** + * Gets a list of messages that exist on a thread. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
run_idStringNoFilter messages by the run ID that generated them.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of messages that exist on a thread as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listMessages(String threadId, RequestOptions requestOptions) { + return new PagedIterable<>(() -> listMessagesSinglePage(threadId, requestOptions)); + } + + /** + * Retrieves an existing message. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMessageWithResponseAsync(String threadId, String messageId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getMessage(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), threadId, messageId, accept, requestOptions, context)); + } + + /** + * Retrieves an existing message. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getMessageWithResponse(String threadId, String messageId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getMessageSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), threadId, + messageId, accept, requestOptions, Context.NONE); + } + + /** + * Modifies an existing message on an existing thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @param updateMessageRequest The updateMessageRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateMessageWithResponseAsync(String threadId, String messageId, + BinaryData updateMessageRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.updateMessage(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + threadId, messageId, contentType, accept, updateMessageRequest, requestOptions, context)); + } + + /** + * Modifies an existing message on an existing thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     thread_id: String (Required)
+     *     status: String(in_progress/incomplete/completed) (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(content_filter/max_tokens/run_cancelled/run_failed/run_expired) (Required)
+     *     }
+     *     completed_at: Long (Required)
+     *     incomplete_at: Long (Required)
+     *     role: String(user/assistant) (Required)
+     *     content (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     assistant_id: String (Required)
+     *     run_id: String (Required)
+     *     attachments (Required): [
+     *          (Required){
+     *             file_id: String (Optional)
+     *             data_source (Optional): {
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *             tools (Required): [
+     *                 BinaryData (Required)
+     *             ]
+     *         }
+     *     ]
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param messageId Identifier of the message. + * @param updateMessageRequest The updateMessageRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single, existing message within an agent thread along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateMessageWithResponse(String threadId, String messageId, + BinaryData updateMessageRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.updateMessageSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + threadId, messageId, contentType, accept, updateMessageRequest, requestOptions, Context.NONE); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/MultipartFormDataHelper.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/MultipartFormDataHelper.java new file mode 100644 index 000000000000..aa08f906286b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/MultipartFormDataHelper.java @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent.implementation; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.SequenceInputStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.UUID; + +// DO NOT modify this helper class + +public final class MultipartFormDataHelper { + /** + * Line separator for the multipart HTTP request. + */ + private static final String CRLF = "\r\n"; + + private static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + /** + * Value to be used as part of the divider for the multipart requests. + */ + private final String boundary; + + /** + * The actual part separator in the request. This is obtained by prepending "--" to the "boundary". + */ + private final String partSeparator; + + /** + * The marker for the ending of a multipart request. This is obtained by post-pending "--" to the "partSeparator". + */ + private final String endMarker; + + /** + * Charset used for encoding the multipart HTTP request. + */ + private final Charset encoderCharset = StandardCharsets.UTF_8; + + private InputStream requestDataStream = new ByteArrayInputStream(new byte[0]); + private long requestLength = 0; + + private RequestOptions requestOptions; + private BinaryData requestBody; + + /** + * Default constructor used in the code. The boundary is a random value. + * + * @param requestOptions the RequestOptions to update + */ + public MultipartFormDataHelper(RequestOptions requestOptions) { + this(requestOptions, UUID.randomUUID().toString().substring(0, 16)); + } + + private MultipartFormDataHelper(RequestOptions requestOptions, String boundary) { + this.requestOptions = requestOptions; + this.boundary = boundary; + this.partSeparator = "--" + boundary; + this.endMarker = this.partSeparator + "--"; + } + + /** + * Gets the multipart HTTP request body. + * + * @return the BinaryData of the multipart HTTP request body + */ + public BinaryData getRequestBody() { + return requestBody; + } + + // text/plain + /** + * Formats a text/plain field for a multipart HTTP request. + * + * @param fieldName the field name + * @param value the value of the text/plain field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeTextField(String fieldName, String value) { + if (value != null) { + String serialized = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + + "\"" + CRLF + CRLF + value + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + // application/json + /** + * Formats a application/json field for a multipart HTTP request. + * + * @param fieldName the field name + * @param jsonObject the object of the application/json field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeJsonField(String fieldName, Object jsonObject) { + if (jsonObject != null) { + String serialized + = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + CRLF + + "Content-Type: application/json" + CRLF + CRLF + BinaryData.fromObject(jsonObject) + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + /** + * Formats a file field for a multipart HTTP request. + * + * @param fieldName the field name + * @param file the BinaryData of the file + * @param contentType the content-type of the file + * @param filename the filename + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileField(String fieldName, BinaryData file, String contentType, + String filename) { + if (file != null) { + if (CoreUtils.isNullOrEmpty(contentType)) { + contentType = APPLICATION_OCTET_STREAM; + } + writeFileField(fieldName, file, contentType, filename); + } + return this; + } + + /** + * Formats a file field (potentially multiple files) for a multipart HTTP request. + * + * @param fieldName the field name + * @param files the List of BinaryData of the files + * @param contentTypes the List of content-type of the files + * @param filenames the List of filenames + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileFields(String fieldName, List files, + List contentTypes, List filenames) { + if (files != null) { + for (int i = 0; i < files.size(); ++i) { + BinaryData file = files.get(i); + String contentType = contentTypes.get(i); + if (CoreUtils.isNullOrEmpty(contentType)) { + contentType = APPLICATION_OCTET_STREAM; + } + String filename = filenames.get(i); + writeFileField(fieldName, file, contentType, filename); + } + } + return this; + } + + /** + * Ends the serialization of the multipart HTTP request. + * + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper end() { + byte[] data = endMarker.getBytes(encoderCharset); + appendBytes(data); + + requestBody = BinaryData.fromStream(requestDataStream, requestLength); + + requestOptions.setHeader(HttpHeaderName.CONTENT_TYPE, "multipart/form-data; boundary=" + this.boundary) + .setHeader(HttpHeaderName.CONTENT_LENGTH, String.valueOf(requestLength)); + + return this; + } + + private void writeFileField(String fieldName, BinaryData file, String contentType, String filename) { + String contentDispositionFilename = ""; + if (!CoreUtils.isNullOrEmpty(filename)) { + contentDispositionFilename = "; filename=\"" + escapeName(filename) + "\""; + } + + // Multipart preamble + String fileFieldPreamble + = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + + contentDispositionFilename + CRLF + "Content-Type: " + contentType + CRLF + CRLF; + byte[] data = fileFieldPreamble.getBytes(encoderCharset); + appendBytes(data); + + // Writing the file into the request as a byte stream + requestLength += file.getLength(); + requestDataStream = new SequenceInputStream(requestDataStream, file.toStream()); + + // CRLF + data = CRLF.getBytes(encoderCharset); + appendBytes(data); + } + + private void appendBytes(byte[] bytes) { + requestLength += bytes.length; + requestDataStream = new SequenceInputStream(requestDataStream, new ByteArrayInputStream(bytes)); + } + + private static String escapeName(String name) { + return name.replace("\n", "%0A").replace("\r", "%0D").replace("\"", "%22"); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/PersistentAgentsAdministrationClientImpl.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/PersistentAgentsAdministrationClientImpl.java new file mode 100644 index 000000000000..7c2162969324 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/PersistentAgentsAdministrationClientImpl.java @@ -0,0 +1,2082 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent.implementation; + +import com.azure.ai.agents.persistent.AgentsServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the PersistentAgentsAdministrationClient type. + */ +public final class PersistentAgentsAdministrationClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PersistentAgentsAdministrationClientService service; + + /** + * Project endpoint in the form of: + * https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + */ + private final String endpoint; + + /** + * Gets Project endpoint in the form of: + * https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final AgentsServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AgentsServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The ThreadsImpl object to access its operations. + */ + private final ThreadsImpl threads; + + /** + * Gets the ThreadsImpl object to access its operations. + * + * @return the ThreadsImpl object. + */ + public ThreadsImpl getThreads() { + return this.threads; + } + + /** + * The MessagesImpl object to access its operations. + */ + private final MessagesImpl messages; + + /** + * Gets the MessagesImpl object to access its operations. + * + * @return the MessagesImpl object. + */ + public MessagesImpl getMessages() { + return this.messages; + } + + /** + * The RunsImpl object to access its operations. + */ + private final RunsImpl runs; + + /** + * Gets the RunsImpl object to access its operations. + * + * @return the RunsImpl object. + */ + public RunsImpl getRuns() { + return this.runs; + } + + /** + * The RunStepsImpl object to access its operations. + */ + private final RunStepsImpl runSteps; + + /** + * Gets the RunStepsImpl object to access its operations. + * + * @return the RunStepsImpl object. + */ + public RunStepsImpl getRunSteps() { + return this.runSteps; + } + + /** + * The FilesImpl object to access its operations. + */ + private final FilesImpl files; + + /** + * Gets the FilesImpl object to access its operations. + * + * @return the FilesImpl object. + */ + public FilesImpl getFiles() { + return this.files; + } + + /** + * The VectorStoresImpl object to access its operations. + */ + private final VectorStoresImpl vectorStores; + + /** + * Gets the VectorStoresImpl object to access its operations. + * + * @return the VectorStoresImpl object. + */ + public VectorStoresImpl getVectorStores() { + return this.vectorStores; + } + + /** + * The VectorStoreFilesImpl object to access its operations. + */ + private final VectorStoreFilesImpl vectorStoreFiles; + + /** + * Gets the VectorStoreFilesImpl object to access its operations. + * + * @return the VectorStoreFilesImpl object. + */ + public VectorStoreFilesImpl getVectorStoreFiles() { + return this.vectorStoreFiles; + } + + /** + * The VectorStoreFileBatchesImpl object to access its operations. + */ + private final VectorStoreFileBatchesImpl vectorStoreFileBatches; + + /** + * Gets the VectorStoreFileBatchesImpl object to access its operations. + * + * @return the VectorStoreFileBatchesImpl object. + */ + public VectorStoreFileBatchesImpl getVectorStoreFileBatches() { + return this.vectorStoreFileBatches; + } + + /** + * Initializes an instance of PersistentAgentsAdministrationClient client. + * + * @param endpoint Project endpoint in the form of: + * https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + * @param serviceVersion Service version. + */ + public PersistentAgentsAdministrationClientImpl(String endpoint, AgentsServiceVersion serviceVersion) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of PersistentAgentsAdministrationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Project endpoint in the form of: + * https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + * @param serviceVersion Service version. + */ + public PersistentAgentsAdministrationClientImpl(HttpPipeline httpPipeline, String endpoint, + AgentsServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + } + + /** + * Initializes an instance of PersistentAgentsAdministrationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Project endpoint in the form of: + * https://<aiservices-id>.services.ai.azure.com/api/projects/<project-name>. + * @param serviceVersion Service version. + */ + public PersistentAgentsAdministrationClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, AgentsServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.serviceVersion = serviceVersion; + this.threads = new ThreadsImpl(this); + this.messages = new MessagesImpl(this); + this.runs = new RunsImpl(this); + this.runSteps = new RunStepsImpl(this); + this.files = new FilesImpl(this); + this.vectorStores = new VectorStoresImpl(this); + this.vectorStoreFiles = new VectorStoreFilesImpl(this); + this.vectorStoreFileBatches = new VectorStoreFileBatchesImpl(this); + this.service = RestProxy.create(PersistentAgentsAdministrationClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for PersistentAgentsAdministrationClient to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PersistentAgentsAdmi") + public interface PersistentAgentsAdministrationClientService { + @Post("/assistants") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createAgent(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createAgentRequest, + RequestOptions requestOptions, Context context); + + @Post("/assistants") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createAgentSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createAgentRequest, + RequestOptions requestOptions, Context context); + + @Get("/assistants") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listAgents(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/assistants") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listAgentsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/assistants/{assistantId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getAgent(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("assistantId") String assistantId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/assistants/{assistantId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getAgentSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("assistantId") String assistantId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/assistants/{assistantId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> updateAgent(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("assistantId") String assistantId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData updateAgentRequest, RequestOptions requestOptions, + Context context); + + @Post("/assistants/{assistantId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateAgentSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("assistantId") String assistantId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData updateAgentRequest, RequestOptions requestOptions, + Context context); + + @Delete("/assistants/{assistantId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteAgent(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("assistantId") String assistantId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/assistants/{assistantId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteAgentSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("assistantId") String assistantId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/threads/runs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createThreadAndRun(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createThreadAndRunRequest, + RequestOptions requestOptions, Context context); + + @Post("/threads/runs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createThreadAndRunSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createThreadAndRunRequest, + RequestOptions requestOptions, Context context); + } + + /** + * Creates a new agent. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     model: String (Required)
+     *     name: String (Optional)
+     *     description: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createAgentRequest The createAgentRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createAgentWithResponseAsync(BinaryData createAgentRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createAgent(this.getEndpoint(), + this.getServiceVersion().getVersion(), contentType, accept, createAgentRequest, requestOptions, context)); + } + + /** + * Creates a new agent. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     model: String (Required)
+     *     name: String (Optional)
+     *     description: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createAgentRequest The createAgentRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createAgentWithResponse(BinaryData createAgentRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createAgentSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept, + createAgentRequest, requestOptions, Context.NONE); + } + + /** + * Gets a list of agents that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of agents that were previously created along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listAgentsSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listAgents(this.getEndpoint(), this.getServiceVersion().getVersion(), + accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null)); + } + + /** + * Gets a list of agents that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of agents that were previously created as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAgentsAsync(RequestOptions requestOptions) { + return new PagedFlux<>(() -> listAgentsSinglePageAsync(requestOptions)); + } + + /** + * Gets a list of agents that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of agents that were previously created along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listAgentsSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listAgentsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null); + } + + /** + * Gets a list of agents that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of agents that were previously created as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listAgents(RequestOptions requestOptions) { + return new PagedIterable<>(() -> listAgentsSinglePage(requestOptions)); + } + + /** + * Retrieves an existing agent. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param assistantId Identifier of the agent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getAgentWithResponseAsync(String assistantId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getAgent(this.getEndpoint(), + this.getServiceVersion().getVersion(), assistantId, accept, requestOptions, context)); + } + + /** + * Retrieves an existing agent. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param assistantId Identifier of the agent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getAgentWithResponse(String assistantId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAgentSync(this.getEndpoint(), this.getServiceVersion().getVersion(), assistantId, accept, + requestOptions, Context.NONE); + } + + /** + * Modifies an existing agent. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     model: String (Optional)
+     *     name: String (Optional)
+     *     description: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param assistantId The ID of the agent to modify. + * @param updateAgentRequest The updateAgentRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateAgentWithResponseAsync(String assistantId, BinaryData updateAgentRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.updateAgent(this.getEndpoint(), this.getServiceVersion().getVersion(), + assistantId, contentType, accept, updateAgentRequest, requestOptions, context)); + } + + /** + * Modifies an existing agent. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     model: String (Optional)
+     *     name: String (Optional)
+     *     description: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     description: String (Required)
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     temperature: Double (Required)
+     *     top_p: Double (Required)
+     *     response_format: BinaryData (Optional)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param assistantId The ID of the agent to modify. + * @param updateAgentRequest The updateAgentRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return represents an agent that can call the model and use tools along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateAgentWithResponse(String assistantId, BinaryData updateAgentRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.updateAgentSync(this.getEndpoint(), this.getServiceVersion().getVersion(), assistantId, + contentType, accept, updateAgentRequest, requestOptions, Context.NONE); + } + + /** + * Deletes an agent. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param assistantId Identifier of the agent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the status of an agent deletion operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteAgentWithResponseAsync(String assistantId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteAgent(this.getEndpoint(), + this.getServiceVersion().getVersion(), assistantId, accept, requestOptions, context)); + } + + /** + * Deletes an agent. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param assistantId Identifier of the agent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the status of an agent deletion operation along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteAgentWithResponse(String assistantId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteAgentSync(this.getEndpoint(), this.getServiceVersion().getVersion(), assistantId, accept, + requestOptions, Context.NONE); + } + + /** + * Creates a new agent thread and immediately starts a run using that new thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     assistant_id: String (Required)
+     *     thread (Optional): {
+     *         messages (Optional): [
+     *              (Optional){
+     *                 role: String(user/assistant) (Required)
+     *                 content: BinaryData (Required)
+     *                 attachments (Optional): [
+     *                      (Optional){
+     *                         file_id: String (Optional)
+     *                         data_source (Optional): {
+     *                             uri: String (Required)
+     *                             type: String(uri_asset/id_asset) (Required)
+     *                         }
+     *                         tools (Required): [
+     *                             BinaryData (Required)
+     *                         ]
+     *                     }
+     *                 ]
+     *                 metadata (Optional): {
+     *                     String: String (Required)
+     *                 }
+     *             }
+     *         ]
+     *         tool_resources (Optional): {
+     *             code_interpreter (Optional): {
+     *                 file_ids (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 data_sources (Optional): [
+     *                     (recursive schema, see above)
+     *                 ]
+     *             }
+     *             file_search (Optional): {
+     *                 vector_store_ids (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 vector_stores (Optional): [
+     *                      (Optional){
+     *                         name: String (Required)
+     *                         configuration (Required): {
+     *                             data_sources (Required): [
+     *                                 (recursive schema, see above)
+     *                             ]
+     *                         }
+     *                     }
+     *                 ]
+     *             }
+     *             azure_ai_search (Optional): {
+     *                 indexes (Optional): [
+     *                      (Optional){
+     *                         index_connection_id: String (Required)
+     *                         index_name: String (Required)
+     *                         query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                         top_k: Integer (Optional)
+     *                         filter: String (Optional)
+     *                         index_asset_id: String (Optional)
+     *                     }
+     *                 ]
+     *             }
+     *         }
+     *         metadata (Optional): {
+     *             String: String (Required)
+     *         }
+     *     }
+     *     model: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): (recursive schema, see azure_ai_search above)
+     *     }
+     *     stream: Boolean (Optional)
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Optional)
+     *     max_completion_tokens: Integer (Optional)
+     *     truncation_strategy (Optional): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Optional)
+     *     response_format: BinaryData (Optional)
+     *     parallel_tool_calls: Boolean (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param createThreadAndRunRequest The createThreadAndRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createThreadAndRunWithResponseAsync(BinaryData createThreadAndRunRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createThreadAndRun(this.getEndpoint(), this.getServiceVersion().getVersion(), + contentType, accept, createThreadAndRunRequest, requestOptions, context)); + } + + /** + * Creates a new agent thread and immediately starts a run using that new thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     assistant_id: String (Required)
+     *     thread (Optional): {
+     *         messages (Optional): [
+     *              (Optional){
+     *                 role: String(user/assistant) (Required)
+     *                 content: BinaryData (Required)
+     *                 attachments (Optional): [
+     *                      (Optional){
+     *                         file_id: String (Optional)
+     *                         data_source (Optional): {
+     *                             uri: String (Required)
+     *                             type: String(uri_asset/id_asset) (Required)
+     *                         }
+     *                         tools (Required): [
+     *                             BinaryData (Required)
+     *                         ]
+     *                     }
+     *                 ]
+     *                 metadata (Optional): {
+     *                     String: String (Required)
+     *                 }
+     *             }
+     *         ]
+     *         tool_resources (Optional): {
+     *             code_interpreter (Optional): {
+     *                 file_ids (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 data_sources (Optional): [
+     *                     (recursive schema, see above)
+     *                 ]
+     *             }
+     *             file_search (Optional): {
+     *                 vector_store_ids (Optional): [
+     *                     String (Optional)
+     *                 ]
+     *                 vector_stores (Optional): [
+     *                      (Optional){
+     *                         name: String (Required)
+     *                         configuration (Required): {
+     *                             data_sources (Required): [
+     *                                 (recursive schema, see above)
+     *                             ]
+     *                         }
+     *                     }
+     *                 ]
+     *             }
+     *             azure_ai_search (Optional): {
+     *                 indexes (Optional): [
+     *                      (Optional){
+     *                         index_connection_id: String (Required)
+     *                         index_name: String (Required)
+     *                         query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                         top_k: Integer (Optional)
+     *                         filter: String (Optional)
+     *                         index_asset_id: String (Optional)
+     *                     }
+     *                 ]
+     *             }
+     *         }
+     *         metadata (Optional): {
+     *             String: String (Required)
+     *         }
+     *     }
+     *     model: String (Optional)
+     *     instructions: String (Optional)
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): (recursive schema, see azure_ai_search above)
+     *     }
+     *     stream: Boolean (Optional)
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Optional)
+     *     max_completion_tokens: Integer (Optional)
+     *     truncation_strategy (Optional): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Optional)
+     *     response_format: BinaryData (Optional)
+     *     parallel_tool_calls: Boolean (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param createThreadAndRunRequest The createThreadAndRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createThreadAndRunWithResponse(BinaryData createThreadAndRunRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createThreadAndRunSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, + accept, createThreadAndRunRequest, requestOptions, Context.NONE); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/RunStepsImpl.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/RunStepsImpl.java new file mode 100644 index 000000000000..076843ab8ac2 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/RunStepsImpl.java @@ -0,0 +1,578 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent.implementation; + +import com.azure.ai.agents.persistent.AgentsServiceVersion; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in RunSteps. + */ +public final class RunStepsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RunStepsService service; + + /** + * The service client containing this operation class. + */ + private final PersistentAgentsAdministrationClientImpl client; + + /** + * Initializes an instance of RunStepsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RunStepsImpl(PersistentAgentsAdministrationClientImpl client) { + this.service = RestProxy.create(RunStepsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AgentsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PersistentAgentsAdministrationClientRunSteps to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PersistentAgentsAdmi") + public interface RunStepsService { + @Get("/threads/{threadId}/runs/{runId}/steps/{stepId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getRunStep(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("runId") String runId, @PathParam("stepId") String stepId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}/runs/{runId}/steps/{stepId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getRunStepSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("runId") String runId, @PathParam("stepId") String stepId, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}/runs/{runId}/steps") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listRunSteps(@HostParam("endpoint") String endpoint, + @PathParam("threadId") String threadId, @PathParam("runId") String runId, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}/runs/{runId}/steps") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listRunStepsSync(@HostParam("endpoint") String endpoint, + @PathParam("threadId") String threadId, @PathParam("runId") String runId, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + } + + /** + * Retrieves a single run step from a thread run. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     type: String(message_creation/tool_calls) (Required)
+     *     assistant_id: String (Required)
+     *     thread_id: String (Required)
+     *     run_id: String (Required)
+     *     status: String(in_progress/cancelled/failed/completed/expired) (Required)
+     *     step_details (Required): {
+     *         type: String(message_creation/tool_calls) (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String(server_error/rate_limit_exceeded) (Required)
+     *         message: String (Required)
+     *     }
+     *     created_at: long (Required)
+     *     expired_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     usage (Optional): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param stepId Identifier of the run step. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed information about a single step of an agent thread run along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRunStepWithResponseAsync(String threadId, String runId, String stepId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getRunStep(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), threadId, runId, stepId, accept, requestOptions, context)); + } + + /** + * Retrieves a single run step from a thread run. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     type: String(message_creation/tool_calls) (Required)
+     *     assistant_id: String (Required)
+     *     thread_id: String (Required)
+     *     run_id: String (Required)
+     *     status: String(in_progress/cancelled/failed/completed/expired) (Required)
+     *     step_details (Required): {
+     *         type: String(message_creation/tool_calls) (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String(server_error/rate_limit_exceeded) (Required)
+     *         message: String (Required)
+     *     }
+     *     created_at: long (Required)
+     *     expired_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     usage (Optional): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param stepId Identifier of the run step. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return detailed information about a single step of an agent thread run along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRunStepWithResponse(String threadId, String runId, String stepId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getRunStepSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), threadId, + runId, stepId, accept, requestOptions, Context.NONE); + } + + /** + * Gets a list of run steps from a thread run. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. In the form of "," separated string.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     type: String(message_creation/tool_calls) (Required)
+     *     assistant_id: String (Required)
+     *     thread_id: String (Required)
+     *     run_id: String (Required)
+     *     status: String(in_progress/cancelled/failed/completed/expired) (Required)
+     *     step_details (Required): {
+     *         type: String(message_creation/tool_calls) (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String(server_error/rate_limit_exceeded) (Required)
+     *         message: String (Required)
+     *     }
+     *     created_at: long (Required)
+     *     expired_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     usage (Optional): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of run steps from a thread run along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listRunStepsSinglePageAsync(String threadId, String runId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listRunSteps(this.client.getEndpoint(), threadId, runId, + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null)); + } + + /** + * Gets a list of run steps from a thread run. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. In the form of "," separated string.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     type: String(message_creation/tool_calls) (Required)
+     *     assistant_id: String (Required)
+     *     thread_id: String (Required)
+     *     run_id: String (Required)
+     *     status: String(in_progress/cancelled/failed/completed/expired) (Required)
+     *     step_details (Required): {
+     *         type: String(message_creation/tool_calls) (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String(server_error/rate_limit_exceeded) (Required)
+     *         message: String (Required)
+     *     }
+     *     created_at: long (Required)
+     *     expired_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     usage (Optional): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of run steps from a thread run as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRunStepsAsync(String threadId, String runId, RequestOptions requestOptions) { + return new PagedFlux<>(() -> listRunStepsSinglePageAsync(threadId, runId, requestOptions)); + } + + /** + * Gets a list of run steps from a thread run. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. In the form of "," separated string.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     type: String(message_creation/tool_calls) (Required)
+     *     assistant_id: String (Required)
+     *     thread_id: String (Required)
+     *     run_id: String (Required)
+     *     status: String(in_progress/cancelled/failed/completed/expired) (Required)
+     *     step_details (Required): {
+     *         type: String(message_creation/tool_calls) (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String(server_error/rate_limit_exceeded) (Required)
+     *         message: String (Required)
+     *     }
+     *     created_at: long (Required)
+     *     expired_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     usage (Optional): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of run steps from a thread run along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listRunStepsSinglePage(String threadId, String runId, + RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listRunStepsSync(this.client.getEndpoint(), threadId, runId, + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null); + } + + /** + * Gets a list of run steps from a thread run. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the + * file search result content. In the form of "," separated string.
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     type: String(message_creation/tool_calls) (Required)
+     *     assistant_id: String (Required)
+     *     thread_id: String (Required)
+     *     run_id: String (Required)
+     *     status: String(in_progress/cancelled/failed/completed/expired) (Required)
+     *     step_details (Required): {
+     *         type: String(message_creation/tool_calls) (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String(server_error/rate_limit_exceeded) (Required)
+     *         message: String (Required)
+     *     }
+     *     created_at: long (Required)
+     *     expired_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     usage (Optional): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of run steps from a thread run as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRunSteps(String threadId, String runId, RequestOptions requestOptions) { + return new PagedIterable<>(() -> listRunStepsSinglePage(threadId, runId, requestOptions)); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/RunsImpl.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/RunsImpl.java new file mode 100644 index 000000000000..0bc59d06f2d2 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/RunsImpl.java @@ -0,0 +1,1884 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent.implementation; + +import com.azure.ai.agents.persistent.AgentsServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Runs. + */ +public final class RunsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RunsService service; + + /** + * The service client containing this operation class. + */ + private final PersistentAgentsAdministrationClientImpl client; + + /** + * Initializes an instance of RunsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RunsImpl(PersistentAgentsAdministrationClientImpl client) { + this.service = RestProxy.create(RunsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AgentsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PersistentAgentsAdministrationClientRuns to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PersistentAgentsAdmi") + public interface RunsService { + @Post("/threads/{threadId}/runs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createRun(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData createRunRequest, RequestOptions requestOptions, Context context); + + @Post("/threads/{threadId}/runs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createRunSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData createRunRequest, RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}/runs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listRuns(@HostParam("endpoint") String endpoint, + @PathParam("threadId") String threadId, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}/runs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listRunsSync(@HostParam("endpoint") String endpoint, + @PathParam("threadId") String threadId, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}/runs/{runId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getRun(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("runId") String runId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/threads/{threadId}/runs/{runId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getRunSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("runId") String runId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Post("/threads/{threadId}/runs/{runId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> updateRun(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("runId") String runId, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData updateRunRequest, + RequestOptions requestOptions, Context context); + + @Post("/threads/{threadId}/runs/{runId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateRunSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("runId") String runId, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData updateRunRequest, + RequestOptions requestOptions, Context context); + + @Post("/threads/{threadId}/runs/{runId}/submit_tool_outputs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> submitToolOutputsToRun(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("runId") String runId, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData submitToolOutputsToRunRequest, RequestOptions requestOptions, + Context context); + + @Post("/threads/{threadId}/runs/{runId}/submit_tool_outputs") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response submitToolOutputsToRunSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("runId") String runId, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData submitToolOutputsToRunRequest, RequestOptions requestOptions, + Context context); + + @Post("/threads/{threadId}/runs/{runId}/cancel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> cancelRun(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("runId") String runId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Post("/threads/{threadId}/runs/{runId}/cancel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response cancelRunSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @PathParam("runId") String runId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Creates a new run for an agent thread. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + * to fetch the file search result content. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     assistant_id: String (Required)
+     *     model: String (Optional)
+     *     instructions: String (Optional)
+     *     additional_instructions: String (Optional)
+     *     additional_messages (Optional): [
+     *          (Optional){
+     *             role: String(user/assistant) (Required)
+     *             content: BinaryData (Required)
+     *             attachments (Optional): [
+     *                  (Optional){
+     *                     file_id: String (Optional)
+     *                     data_source (Optional): {
+     *                         uri: String (Required)
+     *                         type: String(uri_asset/id_asset) (Required)
+     *                     }
+     *                     tools (Required): [
+     *                         BinaryData (Required)
+     *                     ]
+     *                 }
+     *             ]
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     stream: Boolean (Optional)
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Optional)
+     *     max_completion_tokens: Integer (Optional)
+     *     truncation_strategy (Optional): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Optional)
+     *     response_format: BinaryData (Optional)
+     *     parallel_tool_calls: Boolean (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param createRunRequest The createRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createRunWithResponseAsync(String threadId, BinaryData createRunRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createRun(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + threadId, contentType, accept, createRunRequest, requestOptions, context)); + } + + /** + * Creates a new run for an agent thread. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
include[]List<String>NoA list of additional fields to include in the + * response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + * to fetch the file search result content. In the form of "," separated string.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     assistant_id: String (Required)
+     *     model: String (Optional)
+     *     instructions: String (Optional)
+     *     additional_instructions: String (Optional)
+     *     additional_messages (Optional): [
+     *          (Optional){
+     *             role: String(user/assistant) (Required)
+     *             content: BinaryData (Required)
+     *             attachments (Optional): [
+     *                  (Optional){
+     *                     file_id: String (Optional)
+     *                     data_source (Optional): {
+     *                         uri: String (Required)
+     *                         type: String(uri_asset/id_asset) (Required)
+     *                     }
+     *                     tools (Required): [
+     *                         BinaryData (Required)
+     *                     ]
+     *                 }
+     *             ]
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     tools (Optional): [
+     *          (Optional){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     stream: Boolean (Optional)
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Optional)
+     *     max_completion_tokens: Integer (Optional)
+     *     truncation_strategy (Optional): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Optional)
+     *     response_format: BinaryData (Optional)
+     *     parallel_tool_calls: Boolean (Optional)
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param createRunRequest The createRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createRunWithResponse(String threadId, BinaryData createRunRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createRunSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), threadId, + contentType, accept, createRunRequest, requestOptions, Context.NONE); + } + + /** + * Gets a list of runs for a specified thread. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of runs for a specified thread along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listRunsSinglePageAsync(String threadId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listRuns(this.client.getEndpoint(), threadId, + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null)); + } + + /** + * Gets a list of runs for a specified thread. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of runs for a specified thread as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listRunsAsync(String threadId, RequestOptions requestOptions) { + return new PagedFlux<>(() -> listRunsSinglePageAsync(threadId, requestOptions)); + } + + /** + * Gets a list of runs for a specified thread. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of runs for a specified thread along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listRunsSinglePage(String threadId, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listRunsSync(this.client.getEndpoint(), threadId, + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null); + } + + /** + * Gets a list of runs for a specified thread. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of runs for a specified thread as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listRuns(String threadId, RequestOptions requestOptions) { + return new PagedIterable<>(() -> listRunsSinglePage(threadId, requestOptions)); + } + + /** + * Gets an existing run from an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an existing run from an existing thread along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getRunWithResponseAsync(String threadId, String runId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getRun(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), threadId, runId, accept, requestOptions, context)); + } + + /** + * Gets an existing run from an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an existing run from an existing thread along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRunWithResponse(String threadId, String runId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getRunSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), threadId, + runId, accept, requestOptions, Context.NONE); + } + + /** + * Modifies an existing thread run. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param updateRunRequest The updateRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateRunWithResponseAsync(String threadId, String runId, + BinaryData updateRunRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.updateRun(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + threadId, runId, contentType, accept, updateRunRequest, requestOptions, context)); + } + + /** + * Modifies an existing thread run. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param updateRunRequest The updateRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateRunWithResponse(String threadId, String runId, BinaryData updateRunRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.updateRunSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), threadId, + runId, contentType, accept, updateRunRequest, requestOptions, Context.NONE); + } + + /** + * Submits outputs from tools as requested by tool calls in a run. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     tool_outputs (Required): [
+     *          (Required){
+     *             tool_call_id: String (Optional)
+     *             output: String (Optional)
+     *         }
+     *     ]
+     *     stream: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param submitToolOutputsToRunRequest The submitToolOutputsToRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> submitToolOutputsToRunWithResponseAsync(String threadId, String runId, + BinaryData submitToolOutputsToRunRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.submitToolOutputsToRun(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), threadId, runId, contentType, accept, + submitToolOutputsToRunRequest, requestOptions, context)); + } + + /** + * Submits outputs from tools as requested by tool calls in a run. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     tool_outputs (Required): [
+     *          (Required){
+     *             tool_call_id: String (Optional)
+     *             output: String (Optional)
+     *         }
+     *     ]
+     *     stream: Boolean (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param submitToolOutputsToRunRequest The submitToolOutputsToRunRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response submitToolOutputsToRunWithResponse(String threadId, String runId, + BinaryData submitToolOutputsToRunRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.submitToolOutputsToRunSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), threadId, runId, contentType, accept, + submitToolOutputsToRunRequest, requestOptions, Context.NONE); + } + + /** + * Cancels a run of an in‐progress thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> cancelRunWithResponseAsync(String threadId, String runId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.cancelRun(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), threadId, runId, accept, requestOptions, context)); + } + + /** + * Cancels a run of an in‐progress thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     thread_id: String (Required)
+     *     assistant_id: String (Required)
+     *     status: String(queued/in_progress/requires_action/cancelling/cancelled/failed/completed/expired) (Required)
+     *     required_action (Optional): {
+     *         type: String (Required)
+     *     }
+     *     last_error (Required): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *     }
+     *     model: String (Required)
+     *     instructions: String (Required)
+     *     tools (Required): [
+     *          (Required){
+     *             type: String (Required)
+     *         }
+     *     ]
+     *     created_at: long (Required)
+     *     expires_at: Long (Required)
+     *     started_at: Long (Required)
+     *     completed_at: Long (Required)
+     *     cancelled_at: Long (Required)
+     *     failed_at: Long (Required)
+     *     incomplete_details (Required): {
+     *         reason: String(max_completion_tokens/max_prompt_tokens) (Required)
+     *     }
+     *     usage (Required): {
+     *         completion_tokens: long (Required)
+     *         prompt_tokens: long (Required)
+     *         total_tokens: long (Required)
+     *     }
+     *     temperature: Double (Optional)
+     *     top_p: Double (Optional)
+     *     max_prompt_tokens: Integer (Required)
+     *     max_completion_tokens: Integer (Required)
+     *     truncation_strategy (Required): {
+     *         type: String(auto/last_messages) (Required)
+     *         last_messages: Integer (Optional)
+     *     }
+     *     tool_choice: BinaryData (Required)
+     *     response_format: BinaryData (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     parallel_tool_calls: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param runId Identifier of the run. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return data representing a single evaluation run of an agent thread along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response cancelRunWithResponse(String threadId, String runId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.cancelRunSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), threadId, + runId, accept, requestOptions, Context.NONE); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/ThreadsImpl.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/ThreadsImpl.java new file mode 100644 index 000000000000..efb274c10cfa --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/ThreadsImpl.java @@ -0,0 +1,1310 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent.implementation; + +import com.azure.ai.agents.persistent.AgentsServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Threads. + */ +public final class ThreadsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ThreadsService service; + + /** + * The service client containing this operation class. + */ + private final PersistentAgentsAdministrationClientImpl client; + + /** + * Initializes an instance of ThreadsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ThreadsImpl(PersistentAgentsAdministrationClientImpl client) { + this.service = RestProxy.create(ThreadsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AgentsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PersistentAgentsAdministrationClientThreads to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PersistentAgentsAdmi") + public interface ThreadsService { + @Post("/threads") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createThread(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createThreadRequest, + RequestOptions requestOptions, Context context); + + @Post("/threads") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createThreadSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createThreadRequest, + RequestOptions requestOptions, Context context); + + @Get("/threads") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listThreads(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/threads") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listThreadsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getThread(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/threads/{threadId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getThreadSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/threads/{threadId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> updateThread(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData updateThreadRequest, RequestOptions requestOptions, + Context context); + + @Post("/threads/{threadId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response updateThreadSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData updateThreadRequest, RequestOptions requestOptions, + Context context); + + @Delete("/threads/{threadId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteThread(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/threads/{threadId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteThreadSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("threadId") String threadId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Creates a new thread. Threads contain messages and can be run by agents. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     messages (Optional): [
+     *          (Optional){
+     *             role: String(user/assistant) (Required)
+     *             content: BinaryData (Required)
+     *             attachments (Optional): [
+     *                  (Optional){
+     *                     file_id: String (Optional)
+     *                     data_source (Optional): {
+     *                         uri: String (Required)
+     *                         type: String(uri_asset/id_asset) (Required)
+     *                     }
+     *                     tools (Required): [
+     *                         BinaryData (Required)
+     *                     ]
+     *                 }
+     *             ]
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                 (recursive schema, see above)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createThreadRequest The createThreadRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about a single thread associated with an agent along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createThreadWithResponseAsync(BinaryData createThreadRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.createThread(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + contentType, accept, createThreadRequest, requestOptions, context)); + } + + /** + * Creates a new thread. Threads contain messages and can be run by agents. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     messages (Optional): [
+     *          (Optional){
+     *             role: String(user/assistant) (Required)
+     *             content: BinaryData (Required)
+     *             attachments (Optional): [
+     *                  (Optional){
+     *                     file_id: String (Optional)
+     *                     data_source (Optional): {
+     *                         uri: String (Required)
+     *                         type: String(uri_asset/id_asset) (Required)
+     *                     }
+     *                     tools (Required): [
+     *                         BinaryData (Required)
+     *                     ]
+     *                 }
+     *             ]
+     *             metadata (Optional): {
+     *                 String: String (Required)
+     *             }
+     *         }
+     *     ]
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                 (recursive schema, see above)
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createThreadRequest The createThreadRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about a single thread associated with an agent along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createThreadWithResponse(BinaryData createThreadRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createThreadSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + contentType, accept, createThreadRequest, requestOptions, Context.NONE); + } + + /** + * Gets a list of threads that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of threads that were previously created along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listThreadsSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listThreads(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null)); + } + + /** + * Gets a list of threads that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of threads that were previously created as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listThreadsAsync(RequestOptions requestOptions) { + return new PagedFlux<>(() -> listThreadsSinglePageAsync(requestOptions)); + } + + /** + * Gets a list of threads that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of threads that were previously created along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listThreadsSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listThreadsSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null); + } + + /** + * Gets a list of threads that were previously created. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a list of threads that were previously created as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listThreads(RequestOptions requestOptions) { + return new PagedIterable<>(() -> listThreadsSinglePage(requestOptions)); + } + + /** + * Gets information about an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about an existing thread along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getThreadWithResponseAsync(String threadId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getThread(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), threadId, accept, requestOptions, context)); + } + + /** + * Gets information about an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about an existing thread along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getThreadWithResponse(String threadId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getThreadSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), threadId, + accept, requestOptions, Context.NONE); + } + + /** + * Modifies an existing thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId The ID of the thread to modify. + * @param updateThreadRequest The updateThreadRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about a single thread associated with an agent along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateThreadWithResponseAsync(String threadId, BinaryData updateThreadRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.updateThread(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + threadId, contentType, accept, updateThreadRequest, requestOptions, context)); + } + + /** + * Modifies an existing thread. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     tool_resources (Optional): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     tool_resources (Required): {
+     *         code_interpreter (Optional): {
+     *             file_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             data_sources (Optional): [
+     *                  (Optional){
+     *                     uri: String (Required)
+     *                     type: String(uri_asset/id_asset) (Required)
+     *                 }
+     *             ]
+     *         }
+     *         file_search (Optional): {
+     *             vector_store_ids (Optional): [
+     *                 String (Optional)
+     *             ]
+     *             vector_stores (Optional): [
+     *                  (Optional){
+     *                     name: String (Required)
+     *                     configuration (Required): {
+     *                         data_sources (Required): [
+     *                             (recursive schema, see above)
+     *                         ]
+     *                     }
+     *                 }
+     *             ]
+     *         }
+     *         azure_ai_search (Optional): {
+     *             indexes (Optional): [
+     *                  (Optional){
+     *                     index_connection_id: String (Required)
+     *                     index_name: String (Required)
+     *                     query_type: String(simple/semantic/vector/vector_simple_hybrid/vector_semantic_hybrid) (Optional)
+     *                     top_k: Integer (Optional)
+     *                     filter: String (Optional)
+     *                     index_asset_id: String (Optional)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param threadId The ID of the thread to modify. + * @param updateThreadRequest The updateThreadRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return information about a single thread associated with an agent along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateThreadWithResponse(String threadId, BinaryData updateThreadRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.updateThreadSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + threadId, contentType, accept, updateThreadRequest, requestOptions, Context.NONE); + } + + /** + * Deletes an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the status of a thread deletion operation along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteThreadWithResponseAsync(String threadId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteThread(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), threadId, accept, requestOptions, context)); + } + + /** + * Deletes an existing thread. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param threadId Identifier of the thread. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the status of a thread deletion operation along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteThreadWithResponse(String threadId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteThreadSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + threadId, accept, requestOptions, Context.NONE); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoreFileBatchesImpl.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoreFileBatchesImpl.java new file mode 100644 index 000000000000..b6ca925fa7cf --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoreFileBatchesImpl.java @@ -0,0 +1,723 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent.implementation; + +import com.azure.ai.agents.persistent.AgentsServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in VectorStoreFileBatches. + */ +public final class VectorStoreFileBatchesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VectorStoreFileBatchesService service; + + /** + * The service client containing this operation class. + */ + private final PersistentAgentsAdministrationClientImpl client; + + /** + * Initializes an instance of VectorStoreFileBatchesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + VectorStoreFileBatchesImpl(PersistentAgentsAdministrationClientImpl client) { + this.service = RestProxy.create(VectorStoreFileBatchesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AgentsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PersistentAgentsAdministrationClientVectorStoreFileBatches to be used + * by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PersistentAgentsAdmi") + public interface VectorStoreFileBatchesService { + @Post("/vector_stores/{vectorStoreId}/file_batches") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createVectorStoreFileBatch(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData createVectorStoreFileBatchRequest, RequestOptions requestOptions, + Context context); + + @Post("/vector_stores/{vectorStoreId}/file_batches") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createVectorStoreFileBatchSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData createVectorStoreFileBatchRequest, RequestOptions requestOptions, + Context context); + + @Get("/vector_stores/{vectorStoreId}/file_batches/{batchId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getVectorStoreFileBatch(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @PathParam("batchId") String batchId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/vector_stores/{vectorStoreId}/file_batches/{batchId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getVectorStoreFileBatchSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @PathParam("batchId") String batchId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Post("/vector_stores/{vectorStoreId}/file_batches/{batchId}/cancel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> cancelVectorStoreFileBatch(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @PathParam("batchId") String batchId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Post("/vector_stores/{vectorStoreId}/file_batches/{batchId}/cancel") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response cancelVectorStoreFileBatchSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @PathParam("batchId") String batchId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/vector_stores/{vectorStoreId}/file_batches/{batchId}/files") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listVectorStoreFileBatchFiles(@HostParam("endpoint") String endpoint, + @PathParam("vectorStoreId") String vectorStoreId, @PathParam("batchId") String batchId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/vector_stores/{vectorStoreId}/file_batches/{batchId}/files") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listVectorStoreFileBatchFilesSync(@HostParam("endpoint") String endpoint, + @PathParam("vectorStoreId") String vectorStoreId, @PathParam("batchId") String batchId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Create a vector store file batch. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_ids (Optional): [
+     *         String (Optional)
+     *     ]
+     *     data_sources (Optional): [
+     *          (Optional){
+     *             uri: String (Required)
+     *             type: String(uri_asset/id_asset) (Required)
+     *         }
+     *     ]
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param createVectorStoreFileBatchRequest The createVectorStoreFileBatchRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createVectorStoreFileBatchWithResponseAsync(String vectorStoreId, + BinaryData createVectorStoreFileBatchRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createVectorStoreFileBatch(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, contentType, accept, + createVectorStoreFileBatchRequest, requestOptions, context)); + } + + /** + * Create a vector store file batch. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_ids (Optional): [
+     *         String (Optional)
+     *     ]
+     *     data_sources (Optional): [
+     *          (Optional){
+     *             uri: String (Required)
+     *             type: String(uri_asset/id_asset) (Required)
+     *         }
+     *     ]
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param createVectorStoreFileBatchRequest The createVectorStoreFileBatchRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createVectorStoreFileBatchWithResponse(String vectorStoreId, + BinaryData createVectorStoreFileBatchRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createVectorStoreFileBatchSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, contentType, accept, + createVectorStoreFileBatchRequest, requestOptions, Context.NONE); + } + + /** + * Retrieve a vector store file batch. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getVectorStoreFileBatchWithResponseAsync(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getVectorStoreFileBatch(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, batchId, accept, requestOptions, context)); + } + + /** + * Retrieve a vector store file batch. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getVectorStoreFileBatchWithResponse(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getVectorStoreFileBatchSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, batchId, accept, requestOptions, Context.NONE); + } + + /** + * Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as + * possible. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> cancelVectorStoreFileBatchWithResponseAsync(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.cancelVectorStoreFileBatch(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, batchId, accept, requestOptions, context)); + } + + /** + * Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as + * possible. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/cancelled/failed) (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a batch of files attached to a vector store along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response cancelVectorStoreFileBatchWithResponse(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.cancelVectorStoreFileBatchSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, batchId, accept, requestOptions, Context.NONE); + } + + /** + * Returns a list of vector store files in a batch. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listVectorStoreFileBatchFilesSinglePageAsync(String vectorStoreId, + String batchId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listVectorStoreFileBatchFiles(this.client.getEndpoint(), vectorStoreId, + batchId, accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null)); + } + + /** + * Returns a list of vector store files in a batch. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStoreFileBatchFilesAsync(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + return new PagedFlux<>( + () -> listVectorStoreFileBatchFilesSinglePageAsync(vectorStoreId, batchId, requestOptions)); + } + + /** + * Returns a list of vector store files in a batch. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listVectorStoreFileBatchFilesSinglePage(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listVectorStoreFileBatchFilesSync(this.client.getEndpoint(), vectorStoreId, + batchId, accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null); + } + + /** + * Returns a list of vector store files in a batch. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param batchId Identifier of the file batch. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStoreFileBatchFiles(String vectorStoreId, String batchId, + RequestOptions requestOptions) { + return new PagedIterable<>( + () -> listVectorStoreFileBatchFilesSinglePage(vectorStoreId, batchId, requestOptions)); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoreFilesImpl.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoreFilesImpl.java new file mode 100644 index 000000000000..c9adca1dacee --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoreFilesImpl.java @@ -0,0 +1,692 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent.implementation; + +import com.azure.ai.agents.persistent.AgentsServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in VectorStoreFiles. + */ +public final class VectorStoreFilesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VectorStoreFilesService service; + + /** + * The service client containing this operation class. + */ + private final PersistentAgentsAdministrationClientImpl client; + + /** + * Initializes an instance of VectorStoreFilesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + VectorStoreFilesImpl(PersistentAgentsAdministrationClientImpl client) { + this.service + = RestProxy.create(VectorStoreFilesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AgentsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PersistentAgentsAdministrationClientVectorStoreFiles to be used by + * the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PersistentAgentsAdmi") + public interface VectorStoreFilesService { + @Get("/vector_stores/{vectorStoreId}/files") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listVectorStoreFiles(@HostParam("endpoint") String endpoint, + @PathParam("vectorStoreId") String vectorStoreId, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/vector_stores/{vectorStoreId}/files") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listVectorStoreFilesSync(@HostParam("endpoint") String endpoint, + @PathParam("vectorStoreId") String vectorStoreId, @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/vector_stores/{vectorStoreId}/files") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createVectorStoreFile(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData createVectorStoreFileRequest, RequestOptions requestOptions, + Context context); + + @Post("/vector_stores/{vectorStoreId}/files") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createVectorStoreFileSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData createVectorStoreFileRequest, RequestOptions requestOptions, + Context context); + + @Get("/vector_stores/{vectorStoreId}/files/{fileId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getVectorStoreFile(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @PathParam("fileId") String fileId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/vector_stores/{vectorStoreId}/files/{fileId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getVectorStoreFileSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @PathParam("fileId") String fileId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Delete("/vector_stores/{vectorStoreId}/files/{fileId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteVectorStoreFile(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @PathParam("fileId") String fileId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Delete("/vector_stores/{vectorStoreId}/files/{fileId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteVectorStoreFileSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @PathParam("fileId") String fileId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + } + + /** + * Returns a list of vector store files. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listVectorStoreFilesSinglePageAsync(String vectorStoreId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listVectorStoreFiles(this.client.getEndpoint(), vectorStoreId, + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null)); + } + + /** + * Returns a list of vector store files. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStoreFilesAsync(String vectorStoreId, RequestOptions requestOptions) { + return new PagedFlux<>(() -> listVectorStoreFilesSinglePageAsync(vectorStoreId, requestOptions)); + } + + /** + * Returns a list of vector store files. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listVectorStoreFilesSinglePage(String vectorStoreId, + RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listVectorStoreFilesSync(this.client.getEndpoint(), vectorStoreId, + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null); + } + + /** + * Returns a list of vector store files. + *

Query Parameters

+ * + * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
filterStringNoFilter by file status. Allowed values: "in_progress", + * "completed", "failed", "cancelled".
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStoreFiles(String vectorStoreId, RequestOptions requestOptions) { + return new PagedIterable<>(() -> listVectorStoreFilesSinglePage(vectorStoreId, requestOptions)); + } + + /** + * Create a vector store file by attaching a file to a vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_id: String (Optional)
+     *     data_source (Optional): {
+     *         uri: String (Required)
+     *         type: String(uri_asset/id_asset) (Required)
+     *     }
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param createVectorStoreFileRequest The createVectorStoreFileRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return description of a file attached to a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createVectorStoreFileWithResponseAsync(String vectorStoreId, + BinaryData createVectorStoreFileRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createVectorStoreFile(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, contentType, accept, + createVectorStoreFileRequest, requestOptions, context)); + } + + /** + * Create a vector store file by attaching a file to a vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_id: String (Optional)
+     *     data_source (Optional): {
+     *         uri: String (Required)
+     *         type: String(uri_asset/id_asset) (Required)
+     *     }
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param createVectorStoreFileRequest The createVectorStoreFileRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return description of a file attached to a vector store along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createVectorStoreFileWithResponse(String vectorStoreId, + BinaryData createVectorStoreFileRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createVectorStoreFileSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, contentType, accept, + createVectorStoreFileRequest, requestOptions, Context.NONE); + } + + /** + * Retrieves a vector store file. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return description of a file attached to a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getVectorStoreFileWithResponseAsync(String vectorStoreId, String fileId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getVectorStoreFile(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, fileId, accept, requestOptions, context)); + } + + /** + * Retrieves a vector store file. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     usage_bytes: int (Required)
+     *     created_at: long (Required)
+     *     vector_store_id: String (Required)
+     *     status: String(in_progress/completed/failed/cancelled) (Required)
+     *     last_error (Required): {
+     *         code: String(server_error/invalid_file/unsupported_file) (Required)
+     *         message: String (Required)
+     *     }
+     *     chunking_strategy (Required): {
+     *         type: String(other/static) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return description of a file attached to a vector store along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getVectorStoreFileWithResponse(String vectorStoreId, String fileId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getVectorStoreFileSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + vectorStoreId, fileId, accept, requestOptions, Context.NONE); + } + + /** + * Deletes a vector store file. This removes the file‐to‐store link (does not delete the file itself). + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return response object for deleting a vector store file relationship along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteVectorStoreFileWithResponseAsync(String vectorStoreId, String fileId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteVectorStoreFile(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, fileId, accept, requestOptions, context)); + } + + /** + * Deletes a vector store file. This removes the file‐to‐store link (does not delete the file itself). + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param fileId Identifier of the file. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return response object for deleting a vector store file relationship along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteVectorStoreFileWithResponse(String vectorStoreId, String fileId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteVectorStoreFileSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, fileId, accept, requestOptions, Context.NONE); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoresImpl.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoresImpl.java new file mode 100644 index 000000000000..3ca354e0bbb5 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/VectorStoresImpl.java @@ -0,0 +1,928 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent.implementation; + +import com.azure.ai.agents.persistent.AgentsServiceVersion; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in VectorStores. + */ +public final class VectorStoresImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VectorStoresService service; + + /** + * The service client containing this operation class. + */ + private final PersistentAgentsAdministrationClientImpl client; + + /** + * Initializes an instance of VectorStoresImpl. + * + * @param client the instance of the service client containing this operation class. + */ + VectorStoresImpl(PersistentAgentsAdministrationClientImpl client) { + this.service + = RestProxy.create(VectorStoresService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AgentsServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for PersistentAgentsAdministrationClientVectorStores to be used by the + * proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "PersistentAgentsAdmi") + public interface VectorStoresService { + @Get("/vector_stores") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listVectorStores(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/vector_stores") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listVectorStoresSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Post("/vector_stores") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> createVectorStore(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createVectorStoreRequest, + RequestOptions requestOptions, Context context); + + @Post("/vector_stores") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response createVectorStoreSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createVectorStoreRequest, + RequestOptions requestOptions, Context context); + + @Get("/vector_stores/{vectorStoreId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getVectorStore(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/vector_stores/{vectorStoreId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getVectorStoreSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/vector_stores/{vectorStoreId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> modifyVectorStore(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData modifyVectorStoreRequest, RequestOptions requestOptions, + Context context); + + @Post("/vector_stores/{vectorStoreId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response modifyVectorStoreSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData modifyVectorStoreRequest, RequestOptions requestOptions, + Context context); + + @Delete("/vector_stores/{vectorStoreId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteVectorStore(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/vector_stores/{vectorStoreId}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteVectorStoreSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("vectorStoreId") String vectorStoreId, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * Returns a list of vector stores. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items along with {@link PagedResponse} on successful completion + * of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listVectorStoresSinglePageAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listVectorStores(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, context)) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null)); + } + + /** + * Returns a list of vector stores. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listVectorStoresAsync(RequestOptions requestOptions) { + return new PagedFlux<>(() -> listVectorStoresSinglePageAsync(requestOptions)); + } + + /** + * Returns a list of vector stores. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listVectorStoresSinglePage(RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = service.listVectorStoresSync(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + getValues(res.getValue(), "data"), null, null); + } + + /** + * Returns a list of vector stores. + *

Query Parameters

+ * + * + * + * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
limitIntegerNoA limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the default is 20.
orderStringNoSort order by the created_at timestamp of the objects. asc for + * ascending order and desc for descending order. Allowed values: "asc", "desc".
afterStringNoA 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.
beforeStringNoA 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.
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listVectorStores(RequestOptions requestOptions) { + return new PagedIterable<>(() -> listVectorStoresSinglePage(requestOptions)); + } + + /** + * Creates a vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_ids (Optional): [
+     *         String (Optional)
+     *     ]
+     *     name: String (Optional)
+     *     configuration (Optional): {
+     *         data_sources (Required): [
+     *              (Required){
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *         ]
+     *     }
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createVectorStoreRequest The createVectorStoreRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createVectorStoreWithResponseAsync(BinaryData createVectorStoreRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createVectorStore(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), contentType, accept, createVectorStoreRequest, requestOptions, + context)); + } + + /** + * Creates a vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     file_ids (Optional): [
+     *         String (Optional)
+     *     ]
+     *     name: String (Optional)
+     *     configuration (Optional): {
+     *         data_sources (Required): [
+     *              (Required){
+     *                 uri: String (Required)
+     *                 type: String(uri_asset/id_asset) (Required)
+     *             }
+     *         ]
+     *     }
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     chunking_strategy (Optional): {
+     *         type: String(auto/static) (Required)
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param createVectorStoreRequest The createVectorStoreRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createVectorStoreWithResponse(BinaryData createVectorStoreRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createVectorStoreSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + contentType, accept, createVectorStoreRequest, requestOptions, Context.NONE); + } + + /** + * Returns the vector store object matching the specified ID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getVectorStoreWithResponseAsync(String vectorStoreId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.getVectorStore(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, accept, requestOptions, context)); + } + + /** + * Returns the vector store object matching the specified ID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getVectorStoreWithResponse(String vectorStoreId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getVectorStoreSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + vectorStoreId, accept, requestOptions, Context.NONE); + } + + /** + * Modifies an existing vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Optional)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param modifyVectorStoreRequest The modifyVectorStoreRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> modifyVectorStoreWithResponseAsync(String vectorStoreId, + BinaryData modifyVectorStoreRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.modifyVectorStore(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, contentType, accept, modifyVectorStoreRequest, + requestOptions, context)); + } + + /** + * Modifies an existing vector store. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Optional)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     metadata (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     object: String (Required)
+     *     created_at: long (Required)
+     *     name: String (Required)
+     *     usage_bytes: int (Required)
+     *     file_counts (Required): {
+     *         in_progress: int (Required)
+     *         completed: int (Required)
+     *         failed: int (Required)
+     *         cancelled: int (Required)
+     *         total: int (Required)
+     *     }
+     *     status: String(expired/in_progress/completed) (Required)
+     *     expires_after (Optional): {
+     *         anchor: String(last_active_at) (Required)
+     *         days: int (Required)
+     *     }
+     *     expires_at: Long (Optional)
+     *     last_active_at: Long (Required)
+     *     metadata (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param modifyVectorStoreRequest The modifyVectorStoreRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a vector store is a collection of processed files can be used by the `file_search` tool along with + * {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response modifyVectorStoreWithResponse(String vectorStoreId, BinaryData modifyVectorStoreRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.modifyVectorStoreSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + vectorStoreId, contentType, accept, modifyVectorStoreRequest, requestOptions, Context.NONE); + } + + /** + * Deletes the vector store object matching the specified ID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return response object for deleting a vector store along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteVectorStoreWithResponseAsync(String vectorStoreId, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteVectorStore(this.client.getEndpoint(), + this.client.getServiceVersion().getVersion(), vectorStoreId, accept, requestOptions, context)); + } + + /** + * Deletes the vector store object matching the specified ID. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     deleted: boolean (Required)
+     *     object: String (Required)
+     * }
+     * }
+     * 
+ * + * @param vectorStoreId Identifier of the vector store. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return response object for deleting a vector store along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteVectorStoreWithResponse(String vectorStoreId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.deleteVectorStoreSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), + vectorStoreId, accept, requestOptions, Context.NONE); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateAgentRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateAgentRequest.java new file mode 100644 index 000000000000..aeb29737111b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateAgentRequest.java @@ -0,0 +1,418 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.ToolDefinition; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The CreateAgentRequest model. + */ +@Fluent +public final class CreateAgentRequest implements JsonSerializable { + + /* + * The ID of the model to use. + */ + @Generated + private final String model; + + /* + * The name of the new agent. + */ + @Generated + private String name; + + /* + * The description of the new agent. + */ + @Generated + private String description; + + /* + * The system instructions for the new agent to use. + */ + @Generated + private String instructions; + + /* + * The collection of tools to enable for the new agent. + */ + @Generated + private List tools; + + /* + * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For + * example, the `code_interpreter` + * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + */ + @Generated + private ToolResources toolResources; + + /* + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + */ + @Generated + private Double temperature; + + /* + * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of + * the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + */ + @Generated + private Double topP; + + /* + * The response format of the tool calls used by this agent. + */ + @Generated + private BinaryData responseFormat; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of CreateAgentRequest class. + * + * @param model the model value to set. + */ + @Generated + public CreateAgentRequest(String model) { + this.model = model; + } + + /** + * Get the model property: The ID of the model to use. + * + * @return the model value. + */ + @Generated + public String getModel() { + return this.model; + } + + /** + * Get the name property: The name of the new agent. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The name of the new agent. + * + * @param name the name value to set. + * @return the CreateAgentRequest object itself. + */ + @Generated + public CreateAgentRequest setName(String name) { + this.name = name; + return this; + } + + /** + * Get the description property: The description of the new agent. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description of the new agent. + * + * @param description the description value to set. + * @return the CreateAgentRequest object itself. + */ + @Generated + public CreateAgentRequest setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the instructions property: The system instructions for the new agent to use. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Set the instructions property: The system instructions for the new agent to use. + * + * @param instructions the instructions value to set. + * @return the CreateAgentRequest object itself. + */ + @Generated + public CreateAgentRequest setInstructions(String instructions) { + this.instructions = instructions; + return this; + } + + /** + * Get the tools property: The collection of tools to enable for the new agent. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * Set the tools property: The collection of tools to enable for the new agent. + * + * @param tools the tools value to set. + * @return the CreateAgentRequest object itself. + */ + @Generated + public CreateAgentRequest setTools(List tools) { + this.tools = tools; + return this; + } + + /** + * Get the toolResources property: A set of resources that are used by the agent's tools. The resources are specific + * to the type of tool. For example, the `code_interpreter` + * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * + * @return the toolResources value. + */ + @Generated + public ToolResources getToolResources() { + return this.toolResources; + } + + /** + * Set the toolResources property: A set of resources that are used by the agent's tools. The resources are specific + * to the type of tool. For example, the `code_interpreter` + * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * + * @param toolResources the toolResources value to set. + * @return the CreateAgentRequest object itself. + */ + @Generated + public CreateAgentRequest setToolResources(ToolResources toolResources) { + this.toolResources = toolResources; + return this; + } + + /** + * Get the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + * + * @return the temperature value. + */ + @Generated + public Double getTemperature() { + return this.temperature; + } + + /** + * Set the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + * + * @param temperature the temperature value to set. + * @return the CreateAgentRequest object itself. + */ + @Generated + public CreateAgentRequest setTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + /** + * Get the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @return the topP value. + */ + @Generated + public Double getTopP() { + return this.topP; + } + + /** + * Set the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @param topP the topP value to set. + * @return the CreateAgentRequest object itself. + */ + @Generated + public CreateAgentRequest setTopP(Double topP) { + this.topP = topP; + return this; + } + + /** + * Get the responseFormat property: The response format of the tool calls used by this agent. + * + * @return the responseFormat value. + */ + @Generated + public BinaryData getResponseFormat() { + return this.responseFormat; + } + + /** + * Set the responseFormat property: The response format of the tool calls used by this agent. + * + * @param responseFormat the responseFormat value to set. + * @return the CreateAgentRequest object itself. + */ + @Generated + public CreateAgentRequest setResponseFormat(BinaryData responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the CreateAgentRequest object itself. + */ + @Generated + public CreateAgentRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("model", this.model); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("instructions", this.instructions); + jsonWriter.writeArrayField("tools", this.tools, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("tool_resources", this.toolResources); + jsonWriter.writeNumberField("temperature", this.temperature); + jsonWriter.writeNumberField("top_p", this.topP); + if (this.responseFormat != null) { + jsonWriter.writeFieldName("response_format"); + this.responseFormat.writeTo(jsonWriter); + } + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateAgentRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateAgentRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CreateAgentRequest. + */ + @Generated + public static CreateAgentRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String model = null; + String name = null; + String description = null; + String instructions = null; + List tools = null; + ToolResources toolResources = null; + Double temperature = null; + Double topP = null; + BinaryData responseFormat = null; + Map metadata = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("model".equals(fieldName)) { + model = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("instructions".equals(fieldName)) { + instructions = reader.getString(); + } else if ("tools".equals(fieldName)) { + tools = reader.readArray(reader1 -> ToolDefinition.fromJson(reader1)); + } else if ("tool_resources".equals(fieldName)) { + toolResources = ToolResources.fromJson(reader); + } else if ("temperature".equals(fieldName)) { + temperature = reader.getNullable(JsonReader::getDouble); + } else if ("top_p".equals(fieldName)) { + topP = reader.getNullable(JsonReader::getDouble); + } else if ("response_format".equals(fieldName)) { + responseFormat + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + CreateAgentRequest deserializedCreateAgentRequest = new CreateAgentRequest(model); + deserializedCreateAgentRequest.name = name; + deserializedCreateAgentRequest.description = description; + deserializedCreateAgentRequest.instructions = instructions; + deserializedCreateAgentRequest.tools = tools; + deserializedCreateAgentRequest.toolResources = toolResources; + deserializedCreateAgentRequest.temperature = temperature; + deserializedCreateAgentRequest.topP = topP; + deserializedCreateAgentRequest.responseFormat = responseFormat; + deserializedCreateAgentRequest.metadata = metadata; + return deserializedCreateAgentRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateMessageRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateMessageRequest.java new file mode 100644 index 000000000000..88f7b4dd193b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateMessageRequest.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.MessageAttachment; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The CreateMessageRequest model. + */ +@Fluent +public final class CreateMessageRequest implements JsonSerializable { + + /* + * The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + */ + @Generated + private final MessageRole role; + + /* + * The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + */ + @Generated + private final BinaryData content; + + /* + * A list of files attached to the message, and the tools they should be added to. + */ + @Generated + private List attachments; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of CreateMessageRequest class. + * + * @param role the role value to set. + * @param content the content value to set. + */ + @Generated + public CreateMessageRequest(MessageRole role, BinaryData content) { + this.role = role; + this.content = content; + } + + /** + * Get the role property: The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + * + * @return the role value. + */ + @Generated + public MessageRole getRole() { + return this.role; + } + + /** + * Get the content property: The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the attachments property: A list of files attached to the message, and the tools they should be added to. + * + * @return the attachments value. + */ + @Generated + public List getAttachments() { + return this.attachments; + } + + /** + * Set the attachments property: A list of files attached to the message, and the tools they should be added to. + * + * @param attachments the attachments value to set. + * @return the CreateMessageRequest object itself. + */ + @Generated + public CreateMessageRequest setAttachments(List attachments) { + this.attachments = attachments; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the CreateMessageRequest object itself. + */ + @Generated + public CreateMessageRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("role", this.role == null ? null : this.role.toString()); + jsonWriter.writeFieldName("content"); + this.content.writeTo(jsonWriter); + jsonWriter.writeArrayField("attachments", this.attachments, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateMessageRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateMessageRequest if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CreateMessageRequest. + */ + @Generated + public static CreateMessageRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageRole role = null; + BinaryData content = null; + List attachments = null; + Map metadata = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("role".equals(fieldName)) { + role = MessageRole.fromString(reader.getString()); + } else if ("content".equals(fieldName)) { + content = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("attachments".equals(fieldName)) { + attachments = reader.readArray(reader1 -> MessageAttachment.fromJson(reader1)); + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + CreateMessageRequest deserializedCreateMessageRequest = new CreateMessageRequest(role, content); + deserializedCreateMessageRequest.attachments = attachments; + deserializedCreateMessageRequest.metadata = metadata; + return deserializedCreateMessageRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateRunRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateRunRequest.java new file mode 100644 index 000000000000..0331a829a1ca --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateRunRequest.java @@ -0,0 +1,651 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.ThreadMessageOptions; +import com.azure.ai.agents.persistent.models.ToolDefinition; +import com.azure.ai.agents.persistent.models.TruncationObject; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The CreateRunRequest model. + */ +@Fluent +public final class CreateRunRequest implements JsonSerializable { + + /* + * The ID of the agent that should run the thread. + */ + @Generated + private final String assistantId; + + /* + * The overridden model name that the agent should use to run the thread. + */ + @Generated + private String model; + + /* + * The overridden system instructions that the agent should use to run the thread. + */ + @Generated + private String instructions; + + /* + * 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. + */ + @Generated + private String additionalInstructions; + + /* + * Adds additional messages to the thread before creating the run. + */ + @Generated + private List additionalMessages; + + /* + * The overridden list of enabled tools that the agent should use to run the thread. + */ + @Generated + private List tools; + + /* + * If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + */ + @Generated + private Boolean stream; + + /* + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + */ + @Generated + private Double temperature; + + /* + * An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + */ + @Generated + private Double topP; + + /* + * The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort + * to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + */ + @Generated + private Integer maxPromptTokens; + + /* + * The maximum number of completion tokens that may be used over the course of the run. The run will make a best + * effort + * to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the + * number of + * completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + */ + @Generated + private Integer maxCompletionTokens; + + /* + * The strategy to use for dropping messages as the context windows moves forward. + */ + @Generated + private TruncationObject truncationStrategy; + + /* + * Controls whether or not and which tool is called by the model. + */ + @Generated + private BinaryData toolChoice; + + /* + * Specifies the format that the model must output. + */ + @Generated + private BinaryData responseFormat; + + /* + * If `true` functions will run in parallel during tool use. + */ + @Generated + private Boolean parallelToolCalls; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of CreateRunRequest class. + * + * @param assistantId the assistantId value to set. + */ + @Generated + public CreateRunRequest(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Get the assistantId property: The ID of the agent that should run the thread. + * + * @return the assistantId value. + */ + @Generated + public String getAssistantId() { + return this.assistantId; + } + + /** + * Get the model property: The overridden model name that the agent should use to run the thread. + * + * @return the model value. + */ + @Generated + public String getModel() { + return this.model; + } + + /** + * Set the model property: The overridden model name that the agent should use to run the thread. + * + * @param model the model value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setModel(String model) { + this.model = model; + return this; + } + + /** + * Get the instructions property: The overridden system instructions that the agent should use to run the thread. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Set the instructions property: The overridden system instructions that the agent should use to run the thread. + * + * @param instructions the instructions value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setInstructions(String instructions) { + this.instructions = instructions; + return this; + } + + /** + * Get the additionalInstructions property: 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. + * + * @return the additionalInstructions value. + */ + @Generated + public String getAdditionalInstructions() { + return this.additionalInstructions; + } + + /** + * Set the additionalInstructions property: 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. + * + * @param additionalInstructions the additionalInstructions value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setAdditionalInstructions(String additionalInstructions) { + this.additionalInstructions = additionalInstructions; + return this; + } + + /** + * Get the additionalMessages property: Adds additional messages to the thread before creating the run. + * + * @return the additionalMessages value. + */ + @Generated + public List getAdditionalMessages() { + return this.additionalMessages; + } + + /** + * Set the additionalMessages property: Adds additional messages to the thread before creating the run. + * + * @param additionalMessages the additionalMessages value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setAdditionalMessages(List additionalMessages) { + this.additionalMessages = additionalMessages; + return this; + } + + /** + * Get the tools property: The overridden list of enabled tools that the agent should use to run the thread. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * Set the tools property: The overridden list of enabled tools that the agent should use to run the thread. + * + * @param tools the tools value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setTools(List tools) { + this.tools = tools; + return this; + } + + /** + * Get the stream property: If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + * + * @return the stream value. + */ + @Generated + public Boolean isStream() { + return this.stream; + } + + /** + * Set the stream property: If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + * + * @param stream the stream value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setStream(Boolean stream) { + this.stream = stream; + return this; + } + + /** + * Get the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @return the temperature value. + */ + @Generated + public Double getTemperature() { + return this.temperature; + } + + /** + * Set the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @param temperature the temperature value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + /** + * Get the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @return the topP value. + */ + @Generated + public Double getTopP() { + return this.topP; + } + + /** + * Set the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @param topP the topP value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setTopP(Double topP) { + this.topP = topP; + return this; + } + + /** + * Get the maxPromptTokens property: The maximum number of prompt tokens that may be used over the course of the + * run. The run will make a best effort to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @return the maxPromptTokens value. + */ + @Generated + public Integer getMaxPromptTokens() { + return this.maxPromptTokens; + } + + /** + * Set the maxPromptTokens property: The maximum number of prompt tokens that may be used over the course of the + * run. The run will make a best effort to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @param maxPromptTokens the maxPromptTokens value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setMaxPromptTokens(Integer maxPromptTokens) { + this.maxPromptTokens = maxPromptTokens; + return this; + } + + /** + * Get the maxCompletionTokens property: The maximum number of completion tokens that may be used over the course of + * the run. The run will make a best effort + * to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the + * number of + * completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @return the maxCompletionTokens value. + */ + @Generated + public Integer getMaxCompletionTokens() { + return this.maxCompletionTokens; + } + + /** + * Set the maxCompletionTokens property: The maximum number of completion tokens that may be used over the course of + * the run. The run will make a best effort + * to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the + * number of + * completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @param maxCompletionTokens the maxCompletionTokens value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setMaxCompletionTokens(Integer maxCompletionTokens) { + this.maxCompletionTokens = maxCompletionTokens; + return this; + } + + /** + * Get the truncationStrategy property: The strategy to use for dropping messages as the context windows moves + * forward. + * + * @return the truncationStrategy value. + */ + @Generated + public TruncationObject getTruncationStrategy() { + return this.truncationStrategy; + } + + /** + * Set the truncationStrategy property: The strategy to use for dropping messages as the context windows moves + * forward. + * + * @param truncationStrategy the truncationStrategy value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setTruncationStrategy(TruncationObject truncationStrategy) { + this.truncationStrategy = truncationStrategy; + return this; + } + + /** + * Get the toolChoice property: Controls whether or not and which tool is called by the model. + * + * @return the toolChoice value. + */ + @Generated + public BinaryData getToolChoice() { + return this.toolChoice; + } + + /** + * Set the toolChoice property: Controls whether or not and which tool is called by the model. + * + * @param toolChoice the toolChoice value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setToolChoice(BinaryData toolChoice) { + this.toolChoice = toolChoice; + return this; + } + + /** + * Get the responseFormat property: Specifies the format that the model must output. + * + * @return the responseFormat value. + */ + @Generated + public BinaryData getResponseFormat() { + return this.responseFormat; + } + + /** + * Set the responseFormat property: Specifies the format that the model must output. + * + * @param responseFormat the responseFormat value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setResponseFormat(BinaryData responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * Get the parallelToolCalls property: If `true` functions will run in parallel during tool use. + * + * @return the parallelToolCalls value. + */ + @Generated + public Boolean isParallelToolCalls() { + return this.parallelToolCalls; + } + + /** + * Set the parallelToolCalls property: If `true` functions will run in parallel during tool use. + * + * @param parallelToolCalls the parallelToolCalls value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setParallelToolCalls(Boolean parallelToolCalls) { + this.parallelToolCalls = parallelToolCalls; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the CreateRunRequest object itself. + */ + @Generated + public CreateRunRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("assistant_id", this.assistantId); + jsonWriter.writeStringField("model", this.model); + jsonWriter.writeStringField("instructions", this.instructions); + jsonWriter.writeStringField("additional_instructions", this.additionalInstructions); + jsonWriter.writeArrayField("additional_messages", this.additionalMessages, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("tools", this.tools, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeBooleanField("stream", this.stream); + jsonWriter.writeNumberField("temperature", this.temperature); + jsonWriter.writeNumberField("top_p", this.topP); + jsonWriter.writeNumberField("max_prompt_tokens", this.maxPromptTokens); + jsonWriter.writeNumberField("max_completion_tokens", this.maxCompletionTokens); + jsonWriter.writeJsonField("truncation_strategy", this.truncationStrategy); + if (this.toolChoice != null) { + jsonWriter.writeFieldName("tool_choice"); + this.toolChoice.writeTo(jsonWriter); + } + if (this.responseFormat != null) { + jsonWriter.writeFieldName("response_format"); + this.responseFormat.writeTo(jsonWriter); + } + jsonWriter.writeBooleanField("parallel_tool_calls", this.parallelToolCalls); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateRunRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateRunRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CreateRunRequest. + */ + @Generated + public static CreateRunRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String assistantId = null; + String model = null; + String instructions = null; + String additionalInstructions = null; + List additionalMessages = null; + List tools = null; + Boolean stream = null; + Double temperature = null; + Double topP = null; + Integer maxPromptTokens = null; + Integer maxCompletionTokens = null; + TruncationObject truncationStrategy = null; + BinaryData toolChoice = null; + BinaryData responseFormat = null; + Boolean parallelToolCalls = null; + Map metadata = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("assistant_id".equals(fieldName)) { + assistantId = reader.getString(); + } else if ("model".equals(fieldName)) { + model = reader.getString(); + } else if ("instructions".equals(fieldName)) { + instructions = reader.getString(); + } else if ("additional_instructions".equals(fieldName)) { + additionalInstructions = reader.getString(); + } else if ("additional_messages".equals(fieldName)) { + additionalMessages = reader.readArray(reader1 -> ThreadMessageOptions.fromJson(reader1)); + } else if ("tools".equals(fieldName)) { + tools = reader.readArray(reader1 -> ToolDefinition.fromJson(reader1)); + } else if ("stream".equals(fieldName)) { + stream = reader.getNullable(JsonReader::getBoolean); + } else if ("temperature".equals(fieldName)) { + temperature = reader.getNullable(JsonReader::getDouble); + } else if ("top_p".equals(fieldName)) { + topP = reader.getNullable(JsonReader::getDouble); + } else if ("max_prompt_tokens".equals(fieldName)) { + maxPromptTokens = reader.getNullable(JsonReader::getInt); + } else if ("max_completion_tokens".equals(fieldName)) { + maxCompletionTokens = reader.getNullable(JsonReader::getInt); + } else if ("truncation_strategy".equals(fieldName)) { + truncationStrategy = TruncationObject.fromJson(reader); + } else if ("tool_choice".equals(fieldName)) { + toolChoice + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("response_format".equals(fieldName)) { + responseFormat + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("parallel_tool_calls".equals(fieldName)) { + parallelToolCalls = reader.getNullable(JsonReader::getBoolean); + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + CreateRunRequest deserializedCreateRunRequest = new CreateRunRequest(assistantId); + deserializedCreateRunRequest.model = model; + deserializedCreateRunRequest.instructions = instructions; + deserializedCreateRunRequest.additionalInstructions = additionalInstructions; + deserializedCreateRunRequest.additionalMessages = additionalMessages; + deserializedCreateRunRequest.tools = tools; + deserializedCreateRunRequest.stream = stream; + deserializedCreateRunRequest.temperature = temperature; + deserializedCreateRunRequest.topP = topP; + deserializedCreateRunRequest.maxPromptTokens = maxPromptTokens; + deserializedCreateRunRequest.maxCompletionTokens = maxCompletionTokens; + deserializedCreateRunRequest.truncationStrategy = truncationStrategy; + deserializedCreateRunRequest.toolChoice = toolChoice; + deserializedCreateRunRequest.responseFormat = responseFormat; + deserializedCreateRunRequest.parallelToolCalls = parallelToolCalls; + deserializedCreateRunRequest.metadata = metadata; + return deserializedCreateRunRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateThreadAndRunRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateThreadAndRunRequest.java new file mode 100644 index 000000000000..bb7983ccdbdf --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateThreadAndRunRequest.java @@ -0,0 +1,650 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.PersistentAgentThreadCreationOptions; +import com.azure.ai.agents.persistent.models.ToolDefinition; +import com.azure.ai.agents.persistent.models.TruncationObject; +import com.azure.ai.agents.persistent.models.UpdateToolResourcesOptions; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The CreateThreadAndRunRequest model. + */ +@Fluent +public final class CreateThreadAndRunRequest implements JsonSerializable { + + /* + * The ID of the agent for which the thread should be created. + */ + @Generated + private final String assistantId; + + /* + * The details used to create the new thread. If no thread is provided, an empty one will be created. + */ + @Generated + private PersistentAgentThreadCreationOptions thread; + + /* + * The overridden model that the agent should use to run the thread. + */ + @Generated + private String model; + + /* + * The overridden system instructions the agent should use to run the thread. + */ + @Generated + private String instructions; + + /* + * The overridden list of enabled tools the agent should use to run the thread. + */ + @Generated + private List tools; + + /* + * Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis + */ + @Generated + private UpdateToolResourcesOptions toolResources; + + /* + * If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + */ + @Generated + private Boolean stream; + + /* + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + */ + @Generated + private Double temperature; + + /* + * An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + */ + @Generated + private Double topP; + + /* + * The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort + * to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + */ + @Generated + private Integer maxPromptTokens; + + /* + * The maximum number of completion tokens that may be used over the course of the run. The run will make a best + * effort to use only + * the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + * completion tokens + * specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + */ + @Generated + private Integer maxCompletionTokens; + + /* + * The strategy to use for dropping messages as the context windows moves forward. + */ + @Generated + private TruncationObject truncationStrategy; + + /* + * Controls whether or not and which tool is called by the model. + */ + @Generated + private BinaryData toolChoice; + + /* + * Specifies the format that the model must output. + */ + @Generated + private BinaryData responseFormat; + + /* + * If `true` functions will run in parallel during tool use. + */ + @Generated + private Boolean parallelToolCalls; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of CreateThreadAndRunRequest class. + * + * @param assistantId the assistantId value to set. + */ + @Generated + public CreateThreadAndRunRequest(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Get the assistantId property: The ID of the agent for which the thread should be created. + * + * @return the assistantId value. + */ + @Generated + public String getAssistantId() { + return this.assistantId; + } + + /** + * Get the thread property: The details used to create the new thread. If no thread is provided, an empty one will + * be created. + * + * @return the thread value. + */ + @Generated + public PersistentAgentThreadCreationOptions getThread() { + return this.thread; + } + + /** + * Set the thread property: The details used to create the new thread. If no thread is provided, an empty one will + * be created. + * + * @param thread the thread value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setThread(PersistentAgentThreadCreationOptions thread) { + this.thread = thread; + return this; + } + + /** + * Get the model property: The overridden model that the agent should use to run the thread. + * + * @return the model value. + */ + @Generated + public String getModel() { + return this.model; + } + + /** + * Set the model property: The overridden model that the agent should use to run the thread. + * + * @param model the model value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setModel(String model) { + this.model = model; + return this; + } + + /** + * Get the instructions property: The overridden system instructions the agent should use to run the thread. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Set the instructions property: The overridden system instructions the agent should use to run the thread. + * + * @param instructions the instructions value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setInstructions(String instructions) { + this.instructions = instructions; + return this; + } + + /** + * Get the tools property: The overridden list of enabled tools the agent should use to run the thread. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * Set the tools property: The overridden list of enabled tools the agent should use to run the thread. + * + * @param tools the tools value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setTools(List tools) { + this.tools = tools; + return this; + } + + /** + * Get the toolResources property: Override the tools the agent can use for this run. This is useful for modifying + * the behavior on a per-run basis. + * + * @return the toolResources value. + */ + @Generated + public UpdateToolResourcesOptions getToolResources() { + return this.toolResources; + } + + /** + * Set the toolResources property: Override the tools the agent can use for this run. This is useful for modifying + * the behavior on a per-run basis. + * + * @param toolResources the toolResources value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setToolResources(UpdateToolResourcesOptions toolResources) { + this.toolResources = toolResources; + return this; + } + + /** + * Get the stream property: If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + * + * @return the stream value. + */ + @Generated + public Boolean isStream() { + return this.stream; + } + + /** + * Set the stream property: If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + * + * @param stream the stream value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setStream(Boolean stream) { + this.stream = stream; + return this; + } + + /** + * Get the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @return the temperature value. + */ + @Generated + public Double getTemperature() { + return this.temperature; + } + + /** + * Set the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @param temperature the temperature value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + /** + * Get the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @return the topP value. + */ + @Generated + public Double getTopP() { + return this.topP; + } + + /** + * Set the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @param topP the topP value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setTopP(Double topP) { + this.topP = topP; + return this; + } + + /** + * Get the maxPromptTokens property: The maximum number of prompt tokens that may be used over the course of the + * run. The run will make a best effort to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @return the maxPromptTokens value. + */ + @Generated + public Integer getMaxPromptTokens() { + return this.maxPromptTokens; + } + + /** + * Set the maxPromptTokens property: The maximum number of prompt tokens that may be used over the course of the + * run. The run will make a best effort to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @param maxPromptTokens the maxPromptTokens value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setMaxPromptTokens(Integer maxPromptTokens) { + this.maxPromptTokens = maxPromptTokens; + return this; + } + + /** + * Get the maxCompletionTokens property: The maximum number of completion tokens that may be used over the course of + * the run. The run will make a best effort to use only + * the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + * completion tokens + * specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @return the maxCompletionTokens value. + */ + @Generated + public Integer getMaxCompletionTokens() { + return this.maxCompletionTokens; + } + + /** + * Set the maxCompletionTokens property: The maximum number of completion tokens that may be used over the course of + * the run. The run will make a best effort to use only + * the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + * completion tokens + * specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @param maxCompletionTokens the maxCompletionTokens value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setMaxCompletionTokens(Integer maxCompletionTokens) { + this.maxCompletionTokens = maxCompletionTokens; + return this; + } + + /** + * Get the truncationStrategy property: The strategy to use for dropping messages as the context windows moves + * forward. + * + * @return the truncationStrategy value. + */ + @Generated + public TruncationObject getTruncationStrategy() { + return this.truncationStrategy; + } + + /** + * Set the truncationStrategy property: The strategy to use for dropping messages as the context windows moves + * forward. + * + * @param truncationStrategy the truncationStrategy value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setTruncationStrategy(TruncationObject truncationStrategy) { + this.truncationStrategy = truncationStrategy; + return this; + } + + /** + * Get the toolChoice property: Controls whether or not and which tool is called by the model. + * + * @return the toolChoice value. + */ + @Generated + public BinaryData getToolChoice() { + return this.toolChoice; + } + + /** + * Set the toolChoice property: Controls whether or not and which tool is called by the model. + * + * @param toolChoice the toolChoice value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setToolChoice(BinaryData toolChoice) { + this.toolChoice = toolChoice; + return this; + } + + /** + * Get the responseFormat property: Specifies the format that the model must output. + * + * @return the responseFormat value. + */ + @Generated + public BinaryData getResponseFormat() { + return this.responseFormat; + } + + /** + * Set the responseFormat property: Specifies the format that the model must output. + * + * @param responseFormat the responseFormat value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setResponseFormat(BinaryData responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * Get the parallelToolCalls property: If `true` functions will run in parallel during tool use. + * + * @return the parallelToolCalls value. + */ + @Generated + public Boolean isParallelToolCalls() { + return this.parallelToolCalls; + } + + /** + * Set the parallelToolCalls property: If `true` functions will run in parallel during tool use. + * + * @param parallelToolCalls the parallelToolCalls value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setParallelToolCalls(Boolean parallelToolCalls) { + this.parallelToolCalls = parallelToolCalls; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the CreateThreadAndRunRequest object itself. + */ + @Generated + public CreateThreadAndRunRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("assistant_id", this.assistantId); + jsonWriter.writeJsonField("thread", this.thread); + jsonWriter.writeStringField("model", this.model); + jsonWriter.writeStringField("instructions", this.instructions); + jsonWriter.writeArrayField("tools", this.tools, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("tool_resources", this.toolResources); + jsonWriter.writeBooleanField("stream", this.stream); + jsonWriter.writeNumberField("temperature", this.temperature); + jsonWriter.writeNumberField("top_p", this.topP); + jsonWriter.writeNumberField("max_prompt_tokens", this.maxPromptTokens); + jsonWriter.writeNumberField("max_completion_tokens", this.maxCompletionTokens); + jsonWriter.writeJsonField("truncation_strategy", this.truncationStrategy); + if (this.toolChoice != null) { + jsonWriter.writeFieldName("tool_choice"); + this.toolChoice.writeTo(jsonWriter); + } + if (this.responseFormat != null) { + jsonWriter.writeFieldName("response_format"); + this.responseFormat.writeTo(jsonWriter); + } + jsonWriter.writeBooleanField("parallel_tool_calls", this.parallelToolCalls); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateThreadAndRunRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateThreadAndRunRequest if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CreateThreadAndRunRequest. + */ + @Generated + public static CreateThreadAndRunRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String assistantId = null; + PersistentAgentThreadCreationOptions thread = null; + String model = null; + String instructions = null; + List tools = null; + UpdateToolResourcesOptions toolResources = null; + Boolean stream = null; + Double temperature = null; + Double topP = null; + Integer maxPromptTokens = null; + Integer maxCompletionTokens = null; + TruncationObject truncationStrategy = null; + BinaryData toolChoice = null; + BinaryData responseFormat = null; + Boolean parallelToolCalls = null; + Map metadata = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("assistant_id".equals(fieldName)) { + assistantId = reader.getString(); + } else if ("thread".equals(fieldName)) { + thread = PersistentAgentThreadCreationOptions.fromJson(reader); + } else if ("model".equals(fieldName)) { + model = reader.getString(); + } else if ("instructions".equals(fieldName)) { + instructions = reader.getString(); + } else if ("tools".equals(fieldName)) { + tools = reader.readArray(reader1 -> ToolDefinition.fromJson(reader1)); + } else if ("tool_resources".equals(fieldName)) { + toolResources = UpdateToolResourcesOptions.fromJson(reader); + } else if ("stream".equals(fieldName)) { + stream = reader.getNullable(JsonReader::getBoolean); + } else if ("temperature".equals(fieldName)) { + temperature = reader.getNullable(JsonReader::getDouble); + } else if ("top_p".equals(fieldName)) { + topP = reader.getNullable(JsonReader::getDouble); + } else if ("max_prompt_tokens".equals(fieldName)) { + maxPromptTokens = reader.getNullable(JsonReader::getInt); + } else if ("max_completion_tokens".equals(fieldName)) { + maxCompletionTokens = reader.getNullable(JsonReader::getInt); + } else if ("truncation_strategy".equals(fieldName)) { + truncationStrategy = TruncationObject.fromJson(reader); + } else if ("tool_choice".equals(fieldName)) { + toolChoice + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("response_format".equals(fieldName)) { + responseFormat + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("parallel_tool_calls".equals(fieldName)) { + parallelToolCalls = reader.getNullable(JsonReader::getBoolean); + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + CreateThreadAndRunRequest deserializedCreateThreadAndRunRequest + = new CreateThreadAndRunRequest(assistantId); + deserializedCreateThreadAndRunRequest.thread = thread; + deserializedCreateThreadAndRunRequest.model = model; + deserializedCreateThreadAndRunRequest.instructions = instructions; + deserializedCreateThreadAndRunRequest.tools = tools; + deserializedCreateThreadAndRunRequest.toolResources = toolResources; + deserializedCreateThreadAndRunRequest.stream = stream; + deserializedCreateThreadAndRunRequest.temperature = temperature; + deserializedCreateThreadAndRunRequest.topP = topP; + deserializedCreateThreadAndRunRequest.maxPromptTokens = maxPromptTokens; + deserializedCreateThreadAndRunRequest.maxCompletionTokens = maxCompletionTokens; + deserializedCreateThreadAndRunRequest.truncationStrategy = truncationStrategy; + deserializedCreateThreadAndRunRequest.toolChoice = toolChoice; + deserializedCreateThreadAndRunRequest.responseFormat = responseFormat; + deserializedCreateThreadAndRunRequest.parallelToolCalls = parallelToolCalls; + deserializedCreateThreadAndRunRequest.metadata = metadata; + return deserializedCreateThreadAndRunRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateThreadRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateThreadRequest.java new file mode 100644 index 000000000000..f31650fdab29 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateThreadRequest.java @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.ThreadMessageOptions; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The CreateThreadRequest model. + */ +@Fluent +public final class CreateThreadRequest implements JsonSerializable { + + /* + * The initial messages to associate with the new thread. + */ + @Generated + private List messages; + + /* + * A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + */ + @Generated + private ToolResources toolResources; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of CreateThreadRequest class. + */ + @Generated + public CreateThreadRequest() { + } + + /** + * Get the messages property: The initial messages to associate with the new thread. + * + * @return the messages value. + */ + @Generated + public List getMessages() { + return this.messages; + } + + /** + * Set the messages property: The initial messages to associate with the new thread. + * + * @param messages the messages value to set. + * @return the CreateThreadRequest object itself. + */ + @Generated + public CreateThreadRequest setMessages(List messages) { + this.messages = messages; + return this; + } + + /** + * Get the toolResources property: A set of resources that are made available to the agent's tools in this thread. + * The resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + * + * @return the toolResources value. + */ + @Generated + public ToolResources getToolResources() { + return this.toolResources; + } + + /** + * Set the toolResources property: A set of resources that are made available to the agent's tools in this thread. + * The resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + * + * @param toolResources the toolResources value to set. + * @return the CreateThreadRequest object itself. + */ + @Generated + public CreateThreadRequest setToolResources(ToolResources toolResources) { + this.toolResources = toolResources; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the CreateThreadRequest object itself. + */ + @Generated + public CreateThreadRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("messages", this.messages, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("tool_resources", this.toolResources); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateThreadRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateThreadRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the CreateThreadRequest. + */ + @Generated + public static CreateThreadRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CreateThreadRequest deserializedCreateThreadRequest = new CreateThreadRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("messages".equals(fieldName)) { + List messages + = reader.readArray(reader1 -> ThreadMessageOptions.fromJson(reader1)); + deserializedCreateThreadRequest.messages = messages; + } else if ("tool_resources".equals(fieldName)) { + deserializedCreateThreadRequest.toolResources = ToolResources.fromJson(reader); + } else if ("metadata".equals(fieldName)) { + Map metadata = reader.readMap(reader1 -> reader1.getString()); + deserializedCreateThreadRequest.metadata = metadata; + } else { + reader.skipChildren(); + } + } + return deserializedCreateThreadRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreFileBatchRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreFileBatchRequest.java new file mode 100644 index 000000000000..a9335dfa5878 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreFileBatchRequest.java @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequest; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The CreateVectorStoreFileBatchRequest model. + */ +@Fluent +public final class CreateVectorStoreFileBatchRequest implements JsonSerializable { + + /* + * List of file identifiers. + */ + @Generated + private List fileIds; + + /* + * List of Azure assets. + */ + @Generated + private List dataSources; + + /* + * The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + */ + @Generated + private VectorStoreChunkingStrategyRequest chunkingStrategy; + + /** + * Creates an instance of CreateVectorStoreFileBatchRequest class. + */ + @Generated + public CreateVectorStoreFileBatchRequest() { + } + + /** + * Get the fileIds property: List of file identifiers. + * + * @return the fileIds value. + */ + @Generated + public List getFileIds() { + return this.fileIds; + } + + /** + * Set the fileIds property: List of file identifiers. + * + * @param fileIds the fileIds value to set. + * @return the CreateVectorStoreFileBatchRequest object itself. + */ + @Generated + public CreateVectorStoreFileBatchRequest setFileIds(List fileIds) { + this.fileIds = fileIds; + return this; + } + + /** + * Get the dataSources property: List of Azure assets. + * + * @return the dataSources value. + */ + @Generated + public List getDataSources() { + return this.dataSources; + } + + /** + * Set the dataSources property: List of Azure assets. + * + * @param dataSources the dataSources value to set. + * @return the CreateVectorStoreFileBatchRequest object itself. + */ + @Generated + public CreateVectorStoreFileBatchRequest setDataSources(List dataSources) { + this.dataSources = dataSources; + return this; + } + + /** + * Get the chunkingStrategy property: The chunking strategy used to chunk the file(s). If not set, will use the auto + * strategy. + * + * @return the chunkingStrategy value. + */ + @Generated + public VectorStoreChunkingStrategyRequest getChunkingStrategy() { + return this.chunkingStrategy; + } + + /** + * Set the chunkingStrategy property: The chunking strategy used to chunk the file(s). If not set, will use the auto + * strategy. + * + * @param chunkingStrategy the chunkingStrategy value to set. + * @return the CreateVectorStoreFileBatchRequest object itself. + */ + @Generated + public CreateVectorStoreFileBatchRequest setChunkingStrategy(VectorStoreChunkingStrategyRequest chunkingStrategy) { + this.chunkingStrategy = chunkingStrategy; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("file_ids", this.fileIds, (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("data_sources", this.dataSources, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("chunking_strategy", this.chunkingStrategy); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateVectorStoreFileBatchRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateVectorStoreFileBatchRequest if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the CreateVectorStoreFileBatchRequest. + */ + @Generated + public static CreateVectorStoreFileBatchRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CreateVectorStoreFileBatchRequest deserializedCreateVectorStoreFileBatchRequest + = new CreateVectorStoreFileBatchRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_ids".equals(fieldName)) { + List fileIds = reader.readArray(reader1 -> reader1.getString()); + deserializedCreateVectorStoreFileBatchRequest.fileIds = fileIds; + } else if ("data_sources".equals(fieldName)) { + List dataSources + = reader.readArray(reader1 -> VectorStoreDataSource.fromJson(reader1)); + deserializedCreateVectorStoreFileBatchRequest.dataSources = dataSources; + } else if ("chunking_strategy".equals(fieldName)) { + deserializedCreateVectorStoreFileBatchRequest.chunkingStrategy + = VectorStoreChunkingStrategyRequest.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedCreateVectorStoreFileBatchRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreFileRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreFileRequest.java new file mode 100644 index 000000000000..b7d594296649 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreFileRequest.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequest; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The CreateVectorStoreFileRequest model. + */ +@Fluent +public final class CreateVectorStoreFileRequest implements JsonSerializable { + + /* + * Identifier of the file. + */ + @Generated + private String fileId; + + /* + * Azure asset ID. + */ + @Generated + private VectorStoreDataSource dataSource; + + /* + * The chunking strategy used to chunk the file. If not set, uses the auto strategy. + */ + @Generated + private VectorStoreChunkingStrategyRequest chunkingStrategy; + + /** + * Creates an instance of CreateVectorStoreFileRequest class. + */ + @Generated + public CreateVectorStoreFileRequest() { + } + + /** + * Get the fileId property: Identifier of the file. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * Set the fileId property: Identifier of the file. + * + * @param fileId the fileId value to set. + * @return the CreateVectorStoreFileRequest object itself. + */ + @Generated + public CreateVectorStoreFileRequest setFileId(String fileId) { + this.fileId = fileId; + return this; + } + + /** + * Get the dataSource property: Azure asset ID. + * + * @return the dataSource value. + */ + @Generated + public VectorStoreDataSource getDataSource() { + return this.dataSource; + } + + /** + * Set the dataSource property: Azure asset ID. + * + * @param dataSource the dataSource value to set. + * @return the CreateVectorStoreFileRequest object itself. + */ + @Generated + public CreateVectorStoreFileRequest setDataSource(VectorStoreDataSource dataSource) { + this.dataSource = dataSource; + return this; + } + + /** + * Get the chunkingStrategy property: The chunking strategy used to chunk the file. If not set, uses the auto + * strategy. + * + * @return the chunkingStrategy value. + */ + @Generated + public VectorStoreChunkingStrategyRequest getChunkingStrategy() { + return this.chunkingStrategy; + } + + /** + * Set the chunkingStrategy property: The chunking strategy used to chunk the file. If not set, uses the auto + * strategy. + * + * @param chunkingStrategy the chunkingStrategy value to set. + * @return the CreateVectorStoreFileRequest object itself. + */ + @Generated + public CreateVectorStoreFileRequest setChunkingStrategy(VectorStoreChunkingStrategyRequest chunkingStrategy) { + this.chunkingStrategy = chunkingStrategy; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + jsonWriter.writeJsonField("data_source", this.dataSource); + jsonWriter.writeJsonField("chunking_strategy", this.chunkingStrategy); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateVectorStoreFileRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateVectorStoreFileRequest if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the CreateVectorStoreFileRequest. + */ + @Generated + public static CreateVectorStoreFileRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CreateVectorStoreFileRequest deserializedCreateVectorStoreFileRequest = new CreateVectorStoreFileRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + deserializedCreateVectorStoreFileRequest.fileId = reader.getString(); + } else if ("data_source".equals(fieldName)) { + deserializedCreateVectorStoreFileRequest.dataSource = VectorStoreDataSource.fromJson(reader); + } else if ("chunking_strategy".equals(fieldName)) { + deserializedCreateVectorStoreFileRequest.chunkingStrategy + = VectorStoreChunkingStrategyRequest.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedCreateVectorStoreFileRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreRequest.java new file mode 100644 index 000000000000..095929f2f00a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/CreateVectorStoreRequest.java @@ -0,0 +1,266 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequest; +import com.azure.ai.agents.persistent.models.VectorStoreConfiguration; +import com.azure.ai.agents.persistent.models.VectorStoreExpirationPolicy; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The CreateVectorStoreRequest model. + */ +@Fluent +public final class CreateVectorStoreRequest implements JsonSerializable { + + /* + * A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. + */ + @Generated + private List fileIds; + + /* + * The name of the vector store. + */ + @Generated + private String name; + + /* + * The vector store configuration, used when vector store is created from Azure asset URIs. + */ + @Generated + private VectorStoreConfiguration storeConfiguration; + + /* + * Details on when this vector store expires + */ + @Generated + private VectorStoreExpirationPolicy expiresAfter; + + /* + * The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if + * file_ids is non-empty. + */ + @Generated + private VectorStoreChunkingStrategyRequest chunkingStrategy; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of CreateVectorStoreRequest class. + */ + @Generated + public CreateVectorStoreRequest() { + } + + /** + * Get the fileIds property: A list of file IDs that the vector store should use. Useful for tools like + * `file_search` that can access files. + * + * @return the fileIds value. + */ + @Generated + public List getFileIds() { + return this.fileIds; + } + + /** + * Set the fileIds property: A list of file IDs that the vector store should use. Useful for tools like + * `file_search` that can access files. + * + * @param fileIds the fileIds value to set. + * @return the CreateVectorStoreRequest object itself. + */ + @Generated + public CreateVectorStoreRequest setFileIds(List fileIds) { + this.fileIds = fileIds; + return this; + } + + /** + * Get the name property: The name of the vector store. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The name of the vector store. + * + * @param name the name value to set. + * @return the CreateVectorStoreRequest object itself. + */ + @Generated + public CreateVectorStoreRequest setName(String name) { + this.name = name; + return this; + } + + /** + * Get the storeConfiguration property: The vector store configuration, used when vector store is created from Azure + * asset URIs. + * + * @return the storeConfiguration value. + */ + @Generated + public VectorStoreConfiguration getStoreConfiguration() { + return this.storeConfiguration; + } + + /** + * Set the storeConfiguration property: The vector store configuration, used when vector store is created from Azure + * asset URIs. + * + * @param storeConfiguration the storeConfiguration value to set. + * @return the CreateVectorStoreRequest object itself. + */ + @Generated + public CreateVectorStoreRequest setStoreConfiguration(VectorStoreConfiguration storeConfiguration) { + this.storeConfiguration = storeConfiguration; + return this; + } + + /** + * Get the expiresAfter property: Details on when this vector store expires. + * + * @return the expiresAfter value. + */ + @Generated + public VectorStoreExpirationPolicy getExpiresAfter() { + return this.expiresAfter; + } + + /** + * Set the expiresAfter property: Details on when this vector store expires. + * + * @param expiresAfter the expiresAfter value to set. + * @return the CreateVectorStoreRequest object itself. + */ + @Generated + public CreateVectorStoreRequest setExpiresAfter(VectorStoreExpirationPolicy expiresAfter) { + this.expiresAfter = expiresAfter; + return this; + } + + /** + * Get the chunkingStrategy property: The chunking strategy used to chunk the file(s). If not set, will use the auto + * strategy. Only applicable if file_ids is non-empty. + * + * @return the chunkingStrategy value. + */ + @Generated + public VectorStoreChunkingStrategyRequest getChunkingStrategy() { + return this.chunkingStrategy; + } + + /** + * Set the chunkingStrategy property: The chunking strategy used to chunk the file(s). If not set, will use the auto + * strategy. Only applicable if file_ids is non-empty. + * + * @param chunkingStrategy the chunkingStrategy value to set. + * @return the CreateVectorStoreRequest object itself. + */ + @Generated + public CreateVectorStoreRequest setChunkingStrategy(VectorStoreChunkingStrategyRequest chunkingStrategy) { + this.chunkingStrategy = chunkingStrategy; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the CreateVectorStoreRequest object itself. + */ + @Generated + public CreateVectorStoreRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("file_ids", this.fileIds, (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("configuration", this.storeConfiguration); + jsonWriter.writeJsonField("expires_after", this.expiresAfter); + jsonWriter.writeJsonField("chunking_strategy", this.chunkingStrategy); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CreateVectorStoreRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CreateVectorStoreRequest if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the CreateVectorStoreRequest. + */ + @Generated + public static CreateVectorStoreRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CreateVectorStoreRequest deserializedCreateVectorStoreRequest = new CreateVectorStoreRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_ids".equals(fieldName)) { + List fileIds = reader.readArray(reader1 -> reader1.getString()); + deserializedCreateVectorStoreRequest.fileIds = fileIds; + } else if ("name".equals(fieldName)) { + deserializedCreateVectorStoreRequest.name = reader.getString(); + } else if ("configuration".equals(fieldName)) { + deserializedCreateVectorStoreRequest.storeConfiguration = VectorStoreConfiguration.fromJson(reader); + } else if ("expires_after".equals(fieldName)) { + deserializedCreateVectorStoreRequest.expiresAfter = VectorStoreExpirationPolicy.fromJson(reader); + } else if ("chunking_strategy".equals(fieldName)) { + deserializedCreateVectorStoreRequest.chunkingStrategy + = VectorStoreChunkingStrategyRequest.fromJson(reader); + } else if ("metadata".equals(fieldName)) { + Map metadata = reader.readMap(reader1 -> reader1.getString()); + deserializedCreateVectorStoreRequest.metadata = metadata; + } else { + reader.skipChildren(); + } + } + return deserializedCreateVectorStoreRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/FileDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/FileDetails.java new file mode 100644 index 000000000000..fb03d187b48d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/FileDetails.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * A file in an HTTP request, response, or multipart payload. + * + * A file in an HTTP request, response, or multipart payload. + * + * Files have a special meaning that the HTTP library understands. When the body of an HTTP request, response, + * or multipart payload is _effectively_ an instance of `TypeSpec.Http.File` or any type that extends it, the + * operation is treated as a file upload or download. + * + * When using file bodies, the fields of the file model are defined to come from particular locations by default: + * + * - `contentType`: The `Content-Type` header of the request, response, or multipart payload (CANNOT be overridden or + * changed). + * - `contents`: The body of the request, response, or multipart payload (CANNOT be overridden or changed). + * - `filename`: The `filename` parameter value of the `Content-Disposition` header of the response or multipart payload + * (MAY be overridden or changed). + * + * A File may be used as a normal structured JSON object in a request or response, if the request specifies an explicit + * `Content-Type` header. In this case, the entire File model is serialized as if it were any other model. In a JSON + * payload, + * it will have a structure like: + * + * ``` + * { + * "contentType": <string?>, + * "filename": <string?>, + * "contents": <string, base64> + * } + * ``` + * + * The `contentType` _within_ the file defines what media types the data inside the file can be, but if the + * specification + * defines a `Content-Type` for the payload as HTTP metadata, that `Content-Type` metadata defines _how the file is + * serialized_. See the examples below for more information. + * + * NOTE: The `filename` and `contentType` fields are optional. Furthermore, the default location of `filename` + * (`Content-Disposition: <disposition>; filename=<filename>`) is only valid in HTTP responses and multipart + * payloads. If + * you wish to send the `filename` in a request, you must use HTTP metadata decorators to describe the location of the + * `filename` field. You can combine the metadata decorators with `@visibility` to control when the `filename` + * location + * is overridden, as shown in the examples below. + */ +@Fluent +public final class FileDetails { + + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of FileDetails class. + * + * @param content the content value to set. + */ + @Generated + public FileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the FileDetails object itself. + */ + @Generated + public FileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the FileDetails object itself. + */ + @Generated + public FileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/ModifyVectorStoreRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/ModifyVectorStoreRequest.java new file mode 100644 index 000000000000..fd5eb42009d1 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/ModifyVectorStoreRequest.java @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.VectorStoreExpirationPolicy; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * The ModifyVectorStoreRequest model. + */ +@Fluent +public final class ModifyVectorStoreRequest implements JsonSerializable { + + /* + * The name of the vector store. + */ + @Generated + private String name; + + /* + * Details on when this vector store expires + */ + @Generated + private VectorStoreExpirationPolicy expiresAfter; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of ModifyVectorStoreRequest class. + */ + @Generated + public ModifyVectorStoreRequest() { + } + + /** + * Get the name property: The name of the vector store. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The name of the vector store. + * + * @param name the name value to set. + * @return the ModifyVectorStoreRequest object itself. + */ + @Generated + public ModifyVectorStoreRequest setName(String name) { + this.name = name; + return this; + } + + /** + * Get the expiresAfter property: Details on when this vector store expires. + * + * @return the expiresAfter value. + */ + @Generated + public VectorStoreExpirationPolicy getExpiresAfter() { + return this.expiresAfter; + } + + /** + * Set the expiresAfter property: Details on when this vector store expires. + * + * @param expiresAfter the expiresAfter value to set. + * @return the ModifyVectorStoreRequest object itself. + */ + @Generated + public ModifyVectorStoreRequest setExpiresAfter(VectorStoreExpirationPolicy expiresAfter) { + this.expiresAfter = expiresAfter; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the ModifyVectorStoreRequest object itself. + */ + @Generated + public ModifyVectorStoreRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeJsonField("expires_after", this.expiresAfter); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModifyVectorStoreRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModifyVectorStoreRequest if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ModifyVectorStoreRequest. + */ + @Generated + public static ModifyVectorStoreRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ModifyVectorStoreRequest deserializedModifyVectorStoreRequest = new ModifyVectorStoreRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("name".equals(fieldName)) { + deserializedModifyVectorStoreRequest.name = reader.getString(); + } else if ("expires_after".equals(fieldName)) { + deserializedModifyVectorStoreRequest.expiresAfter = VectorStoreExpirationPolicy.fromJson(reader); + } else if ("metadata".equals(fieldName)) { + Map metadata = reader.readMap(reader1 -> reader1.getString()); + deserializedModifyVectorStoreRequest.metadata = metadata; + } else { + reader.skipChildren(); + } + } + return deserializedModifyVectorStoreRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/SubmitToolOutputsToRunRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/SubmitToolOutputsToRunRequest.java new file mode 100644 index 000000000000..20b26b2868c1 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/SubmitToolOutputsToRunRequest.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.ToolOutput; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The SubmitToolOutputsToRunRequest model. + */ +@Fluent +public final class SubmitToolOutputsToRunRequest implements JsonSerializable { + + /* + * A list of tools for which the outputs are being submitted + */ + @Generated + private final List toolOutputs; + + /* + * If true, returns a stream of events that happen during the Run as SSE, terminating at `[DONE]`. + */ + @Generated + private Boolean stream; + + /** + * Creates an instance of SubmitToolOutputsToRunRequest class. + * + * @param toolOutputs the toolOutputs value to set. + */ + @Generated + public SubmitToolOutputsToRunRequest(List toolOutputs) { + this.toolOutputs = toolOutputs; + } + + /** + * Get the toolOutputs property: A list of tools for which the outputs are being submitted. + * + * @return the toolOutputs value. + */ + @Generated + public List getToolOutputs() { + return this.toolOutputs; + } + + /** + * Get the stream property: If true, returns a stream of events that happen during the Run as SSE, terminating at + * `[DONE]`. + * + * @return the stream value. + */ + @Generated + public Boolean isStream() { + return this.stream; + } + + /** + * Set the stream property: If true, returns a stream of events that happen during the Run as SSE, terminating at + * `[DONE]`. + * + * @param stream the stream value to set. + * @return the SubmitToolOutputsToRunRequest object itself. + */ + @Generated + public SubmitToolOutputsToRunRequest setStream(Boolean stream) { + this.stream = stream; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("tool_outputs", this.toolOutputs, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeBooleanField("stream", this.stream); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SubmitToolOutputsToRunRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SubmitToolOutputsToRunRequest if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SubmitToolOutputsToRunRequest. + */ + @Generated + public static SubmitToolOutputsToRunRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List toolOutputs = null; + Boolean stream = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("tool_outputs".equals(fieldName)) { + toolOutputs = reader.readArray(reader1 -> ToolOutput.fromJson(reader1)); + } else if ("stream".equals(fieldName)) { + stream = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + SubmitToolOutputsToRunRequest deserializedSubmitToolOutputsToRunRequest + = new SubmitToolOutputsToRunRequest(toolOutputs); + deserializedSubmitToolOutputsToRunRequest.stream = stream; + return deserializedSubmitToolOutputsToRunRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateAgentRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateAgentRequest.java new file mode 100644 index 000000000000..dd7c5e9b1c8b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateAgentRequest.java @@ -0,0 +1,412 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.ToolDefinition; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The UpdateAgentRequest model. + */ +@Fluent +public final class UpdateAgentRequest implements JsonSerializable { + + /* + * The ID of the model to use. + */ + @Generated + private String model; + + /* + * The modified name for the agent to use. + */ + @Generated + private String name; + + /* + * The modified description for the agent to use. + */ + @Generated + private String description; + + /* + * The modified system instructions for the new agent to use. + */ + @Generated + private String instructions; + + /* + * The modified collection of tools to enable for the agent. + */ + @Generated + private List tools; + + /* + * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For + * example, + * the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector + * store IDs. + */ + @Generated + private ToolResources toolResources; + + /* + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + */ + @Generated + private Double temperature; + + /* + * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of + * the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + */ + @Generated + private Double topP; + + /* + * The response format of the tool calls used by this agent. + */ + @Generated + private BinaryData responseFormat; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of UpdateAgentRequest class. + */ + @Generated + public UpdateAgentRequest() { + } + + /** + * Get the model property: The ID of the model to use. + * + * @return the model value. + */ + @Generated + public String getModel() { + return this.model; + } + + /** + * Set the model property: The ID of the model to use. + * + * @param model the model value to set. + * @return the UpdateAgentRequest object itself. + */ + @Generated + public UpdateAgentRequest setModel(String model) { + this.model = model; + return this; + } + + /** + * Get the name property: The modified name for the agent to use. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The modified name for the agent to use. + * + * @param name the name value to set. + * @return the UpdateAgentRequest object itself. + */ + @Generated + public UpdateAgentRequest setName(String name) { + this.name = name; + return this; + } + + /** + * Get the description property: The modified description for the agent to use. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The modified description for the agent to use. + * + * @param description the description value to set. + * @return the UpdateAgentRequest object itself. + */ + @Generated + public UpdateAgentRequest setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the instructions property: The modified system instructions for the new agent to use. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Set the instructions property: The modified system instructions for the new agent to use. + * + * @param instructions the instructions value to set. + * @return the UpdateAgentRequest object itself. + */ + @Generated + public UpdateAgentRequest setInstructions(String instructions) { + this.instructions = instructions; + return this; + } + + /** + * Get the tools property: The modified collection of tools to enable for the agent. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * Set the tools property: The modified collection of tools to enable for the agent. + * + * @param tools the tools value to set. + * @return the UpdateAgentRequest object itself. + */ + @Generated + public UpdateAgentRequest setTools(List tools) { + this.tools = tools; + return this; + } + + /** + * Get the toolResources property: A set of resources that are used by the agent's tools. The resources are specific + * to the type of tool. For example, + * the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector + * store IDs. + * + * @return the toolResources value. + */ + @Generated + public ToolResources getToolResources() { + return this.toolResources; + } + + /** + * Set the toolResources property: A set of resources that are used by the agent's tools. The resources are specific + * to the type of tool. For example, + * the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector + * store IDs. + * + * @param toolResources the toolResources value to set. + * @return the UpdateAgentRequest object itself. + */ + @Generated + public UpdateAgentRequest setToolResources(ToolResources toolResources) { + this.toolResources = toolResources; + return this; + } + + /** + * Get the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + * + * @return the temperature value. + */ + @Generated + public Double getTemperature() { + return this.temperature; + } + + /** + * Set the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + * + * @param temperature the temperature value to set. + * @return the UpdateAgentRequest object itself. + */ + @Generated + public UpdateAgentRequest setTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + /** + * Get the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @return the topP value. + */ + @Generated + public Double getTopP() { + return this.topP; + } + + /** + * Set the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @param topP the topP value to set. + * @return the UpdateAgentRequest object itself. + */ + @Generated + public UpdateAgentRequest setTopP(Double topP) { + this.topP = topP; + return this; + } + + /** + * Get the responseFormat property: The response format of the tool calls used by this agent. + * + * @return the responseFormat value. + */ + @Generated + public BinaryData getResponseFormat() { + return this.responseFormat; + } + + /** + * Set the responseFormat property: The response format of the tool calls used by this agent. + * + * @param responseFormat the responseFormat value to set. + * @return the UpdateAgentRequest object itself. + */ + @Generated + public UpdateAgentRequest setResponseFormat(BinaryData responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the UpdateAgentRequest object itself. + */ + @Generated + public UpdateAgentRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("model", this.model); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("instructions", this.instructions); + jsonWriter.writeArrayField("tools", this.tools, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("tool_resources", this.toolResources); + jsonWriter.writeNumberField("temperature", this.temperature); + jsonWriter.writeNumberField("top_p", this.topP); + if (this.responseFormat != null) { + jsonWriter.writeFieldName("response_format"); + this.responseFormat.writeTo(jsonWriter); + } + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UpdateAgentRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UpdateAgentRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the UpdateAgentRequest. + */ + @Generated + public static UpdateAgentRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UpdateAgentRequest deserializedUpdateAgentRequest = new UpdateAgentRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("model".equals(fieldName)) { + deserializedUpdateAgentRequest.model = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedUpdateAgentRequest.name = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedUpdateAgentRequest.description = reader.getString(); + } else if ("instructions".equals(fieldName)) { + deserializedUpdateAgentRequest.instructions = reader.getString(); + } else if ("tools".equals(fieldName)) { + List tools = reader.readArray(reader1 -> ToolDefinition.fromJson(reader1)); + deserializedUpdateAgentRequest.tools = tools; + } else if ("tool_resources".equals(fieldName)) { + deserializedUpdateAgentRequest.toolResources = ToolResources.fromJson(reader); + } else if ("temperature".equals(fieldName)) { + deserializedUpdateAgentRequest.temperature = reader.getNullable(JsonReader::getDouble); + } else if ("top_p".equals(fieldName)) { + deserializedUpdateAgentRequest.topP = reader.getNullable(JsonReader::getDouble); + } else if ("response_format".equals(fieldName)) { + deserializedUpdateAgentRequest.responseFormat + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("metadata".equals(fieldName)) { + Map metadata = reader.readMap(reader1 -> reader1.getString()); + deserializedUpdateAgentRequest.metadata = metadata; + } else { + reader.skipChildren(); + } + } + return deserializedUpdateAgentRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateMessageRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateMessageRequest.java new file mode 100644 index 000000000000..752e7bf991a1 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateMessageRequest.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * The UpdateMessageRequest model. + */ +@Fluent +public final class UpdateMessageRequest implements JsonSerializable { + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of UpdateMessageRequest class. + */ + @Generated + public UpdateMessageRequest() { + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the UpdateMessageRequest object itself. + */ + @Generated + public UpdateMessageRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UpdateMessageRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UpdateMessageRequest if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the UpdateMessageRequest. + */ + @Generated + public static UpdateMessageRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UpdateMessageRequest deserializedUpdateMessageRequest = new UpdateMessageRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("metadata".equals(fieldName)) { + Map metadata = reader.readMap(reader1 -> reader1.getString()); + deserializedUpdateMessageRequest.metadata = metadata; + } else { + reader.skipChildren(); + } + } + return deserializedUpdateMessageRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateRunRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateRunRequest.java new file mode 100644 index 000000000000..fab8ea259d4a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateRunRequest.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * The UpdateRunRequest model. + */ +@Fluent +public final class UpdateRunRequest implements JsonSerializable { + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of UpdateRunRequest class. + */ + @Generated + public UpdateRunRequest() { + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the UpdateRunRequest object itself. + */ + @Generated + public UpdateRunRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UpdateRunRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UpdateRunRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the UpdateRunRequest. + */ + @Generated + public static UpdateRunRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UpdateRunRequest deserializedUpdateRunRequest = new UpdateRunRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("metadata".equals(fieldName)) { + Map metadata = reader.readMap(reader1 -> reader1.getString()); + deserializedUpdateRunRequest.metadata = metadata; + } else { + reader.skipChildren(); + } + } + return deserializedUpdateRunRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateThreadRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateThreadRequest.java new file mode 100644 index 000000000000..684d7492b229 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UpdateThreadRequest.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * The UpdateThreadRequest model. + */ +@Fluent +public final class UpdateThreadRequest implements JsonSerializable { + + /* + * A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs + */ + @Generated + private ToolResources toolResources; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of UpdateThreadRequest class. + */ + @Generated + public UpdateThreadRequest() { + } + + /** + * Get the toolResources property: A set of resources that are made available to the agent's tools in this thread. + * The resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + * + * @return the toolResources value. + */ + @Generated + public ToolResources getToolResources() { + return this.toolResources; + } + + /** + * Set the toolResources property: A set of resources that are made available to the agent's tools in this thread. + * The resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + * + * @param toolResources the toolResources value to set. + * @return the UpdateThreadRequest object itself. + */ + @Generated + public UpdateThreadRequest setToolResources(ToolResources toolResources) { + this.toolResources = toolResources; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the UpdateThreadRequest object itself. + */ + @Generated + public UpdateThreadRequest setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("tool_resources", this.toolResources); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UpdateThreadRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UpdateThreadRequest if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the UpdateThreadRequest. + */ + @Generated + public static UpdateThreadRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UpdateThreadRequest deserializedUpdateThreadRequest = new UpdateThreadRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("tool_resources".equals(fieldName)) { + deserializedUpdateThreadRequest.toolResources = ToolResources.fromJson(reader); + } else if ("metadata".equals(fieldName)) { + Map metadata = reader.readMap(reader1 -> reader1.getString()); + deserializedUpdateThreadRequest.metadata = metadata; + } else { + reader.skipChildren(); + } + } + return deserializedUpdateThreadRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UploadFileRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UploadFileRequest.java new file mode 100644 index 000000000000..9cdc229cd85b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/UploadFileRequest.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.implementation.models; + +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; + +/** + * The UploadFileRequest model. + */ +@Fluent +public final class UploadFileRequest { + + /* + * The file data, in bytes. + */ + @Generated + private final FileDetails file; + + /* + * The intended purpose of the uploaded file. Use `assistants` for Agents and Message files, `vision` for Agents + * image file inputs, `batch` for Batch API, and `fine-tune` for Fine-tuning. + */ + @Generated + private final FilePurpose purpose; + + /* + * The name of the file. + */ + @Generated + private String filename; + + /** + * Creates an instance of UploadFileRequest class. + * + * @param file the file value to set. + * @param purpose the purpose value to set. + */ + @Generated + public UploadFileRequest(FileDetails file, FilePurpose purpose) { + this.file = file; + this.purpose = purpose; + } + + /** + * Get the file property: The file data, in bytes. + * + * @return the file value. + */ + @Generated + public FileDetails getFile() { + return this.file; + } + + /** + * Get the purpose property: The intended purpose of the uploaded file. Use `assistants` for Agents and Message + * files, `vision` for Agents image file inputs, `batch` for Batch API, and `fine-tune` for Fine-tuning. + * + * @return the purpose value. + */ + @Generated + public FilePurpose getPurpose() { + return this.purpose; + } + + /** + * Get the filename property: The name of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The name of the file. + * + * @param filename the filename value to set. + * @return the UploadFileRequest object itself. + */ + @Generated + public UploadFileRequest setFilename(String filename) { + this.filename = filename; + return this; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/package-info.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/package-info.java new file mode 100644 index 000000000000..8f609e3b252b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +/** + * + * Package containing the data models for Agents. + * + */ +package com.azure.ai.agents.persistent.implementation.models; diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/package-info.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/package-info.java new file mode 100644 index 000000000000..6804146fce06 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +/** + * + * Package containing the implementations for Agents. + * + */ +package com.azure.ai.agents.persistent.implementation; diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AISearchIndexResource.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AISearchIndexResource.java new file mode 100644 index 000000000000..051b59be6c8e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AISearchIndexResource.java @@ -0,0 +1,238 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A AI Search Index resource. + */ +@Fluent +public final class AISearchIndexResource implements JsonSerializable { + + /* + * An index connection id in an IndexResource attached to this agent. + */ + @Generated + private final String indexConnectionId; + + /* + * The name of an index in an IndexResource attached to this agent. + */ + @Generated + private final String indexName; + + /* + * Type of query in an AIIndexResource attached to this agent. + */ + @Generated + private AzureAISearchQueryType queryType; + + /* + * Number of documents to retrieve from search and present to the model. + */ + @Generated + private Integer topK; + + /* + * filter string for search resource. + */ + @Generated + private String filter; + + /* + * Index asset id for search resource. + */ + @Generated + private String indexAssetId; + + /** + * Creates an instance of AISearchIndexResource class. + * + * @param indexConnectionId the indexConnectionId value to set. + * @param indexName the indexName value to set. + */ + @Generated + public AISearchIndexResource(String indexConnectionId, String indexName) { + this.indexConnectionId = indexConnectionId; + this.indexName = indexName; + } + + /** + * Get the indexConnectionId property: An index connection id in an IndexResource attached to this agent. + * + * @return the indexConnectionId value. + */ + @Generated + public String getIndexConnectionId() { + return this.indexConnectionId; + } + + /** + * Get the indexName property: The name of an index in an IndexResource attached to this agent. + * + * @return the indexName value. + */ + @Generated + public String getIndexName() { + return this.indexName; + } + + /** + * Get the queryType property: Type of query in an AIIndexResource attached to this agent. + * + * @return the queryType value. + */ + @Generated + public AzureAISearchQueryType getQueryType() { + return this.queryType; + } + + /** + * Set the queryType property: Type of query in an AIIndexResource attached to this agent. + * + * @param queryType the queryType value to set. + * @return the AISearchIndexResource object itself. + */ + @Generated + public AISearchIndexResource setQueryType(AzureAISearchQueryType queryType) { + this.queryType = queryType; + return this; + } + + /** + * Get the topK property: Number of documents to retrieve from search and present to the model. + * + * @return the topK value. + */ + @Generated + public Integer getTopK() { + return this.topK; + } + + /** + * Set the topK property: Number of documents to retrieve from search and present to the model. + * + * @param topK the topK value to set. + * @return the AISearchIndexResource object itself. + */ + @Generated + public AISearchIndexResource setTopK(Integer topK) { + this.topK = topK; + return this; + } + + /** + * Get the filter property: filter string for search resource. + * + * @return the filter value. + */ + @Generated + public String getFilter() { + return this.filter; + } + + /** + * Set the filter property: filter string for search resource. + * + * @param filter the filter value to set. + * @return the AISearchIndexResource object itself. + */ + @Generated + public AISearchIndexResource setFilter(String filter) { + this.filter = filter; + return this; + } + + /** + * Get the indexAssetId property: Index asset id for search resource. + * + * @return the indexAssetId value. + */ + @Generated + public String getIndexAssetId() { + return this.indexAssetId; + } + + /** + * Set the indexAssetId property: Index asset id for search resource. + * + * @param indexAssetId the indexAssetId value to set. + * @return the AISearchIndexResource object itself. + */ + @Generated + public AISearchIndexResource setIndexAssetId(String indexAssetId) { + this.indexAssetId = indexAssetId; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("index_connection_id", this.indexConnectionId); + jsonWriter.writeStringField("index_name", this.indexName); + jsonWriter.writeStringField("query_type", this.queryType == null ? null : this.queryType.toString()); + jsonWriter.writeNumberField("top_k", this.topK); + jsonWriter.writeStringField("filter", this.filter); + jsonWriter.writeStringField("index_asset_id", this.indexAssetId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AISearchIndexResource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AISearchIndexResource if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AISearchIndexResource. + */ + @Generated + public static AISearchIndexResource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String indexConnectionId = null; + String indexName = null; + AzureAISearchQueryType queryType = null; + Integer topK = null; + String filter = null; + String indexAssetId = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index_connection_id".equals(fieldName)) { + indexConnectionId = reader.getString(); + } else if ("index_name".equals(fieldName)) { + indexName = reader.getString(); + } else if ("query_type".equals(fieldName)) { + queryType = AzureAISearchQueryType.fromString(reader.getString()); + } else if ("top_k".equals(fieldName)) { + topK = reader.getNullable(JsonReader::getInt); + } else if ("filter".equals(fieldName)) { + filter = reader.getString(); + } else if ("index_asset_id".equals(fieldName)) { + indexAssetId = reader.getString(); + } else { + reader.skipChildren(); + } + } + AISearchIndexResource deserializedAISearchIndexResource + = new AISearchIndexResource(indexConnectionId, indexName); + deserializedAISearchIndexResource.queryType = queryType; + deserializedAISearchIndexResource.topK = topK; + deserializedAISearchIndexResource.filter = filter; + deserializedAISearchIndexResource.indexAssetId = indexAssetId; + return deserializedAISearchIndexResource; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AgentDeletionStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AgentDeletionStatus.java new file mode 100644 index 000000000000..633a2f2080ea --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AgentDeletionStatus.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The status of an agent deletion operation. + */ +@Immutable +public final class AgentDeletionStatus implements JsonSerializable { + + /* + * The ID of the resource specified for deletion. + */ + @Generated + private final String id; + + /* + * A value indicating whether deletion was successful. + */ + @Generated + private final boolean deleted; + + /* + * The object type, which is always 'assistant.deleted'. + */ + @Generated + private final String object = "assistant.deleted"; + + /** + * Creates an instance of AgentDeletionStatus class. + * + * @param id the id value to set. + * @param deleted the deleted value to set. + */ + @Generated + private AgentDeletionStatus(String id, boolean deleted) { + this.id = id; + this.deleted = deleted; + } + + /** + * Get the id property: The ID of the resource specified for deletion. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the deleted property: A value indicating whether deletion was successful. + * + * @return the deleted value. + */ + @Generated + public boolean isDeleted() { + return this.deleted; + } + + /** + * Get the object property: The object type, which is always 'assistant.deleted'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeBooleanField("deleted", this.deleted); + jsonWriter.writeStringField("object", this.object); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AgentDeletionStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AgentDeletionStatus if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AgentDeletionStatus. + */ + @Generated + public static AgentDeletionStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + boolean deleted = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("deleted".equals(fieldName)) { + deleted = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new AgentDeletionStatus(id, deleted); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchQueryType.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchQueryType.java new file mode 100644 index 000000000000..e5b1ba9e94aa --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchQueryType.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Available query types for Azure AI Search tool. + */ +public final class AzureAISearchQueryType extends ExpandableStringEnum { + + /** + * Query type `simple`. + */ + @Generated + public static final AzureAISearchQueryType SIMPLE = fromString("simple"); + + /** + * Query type `semantic`. + */ + @Generated + public static final AzureAISearchQueryType SEMANTIC = fromString("semantic"); + + /** + * Query type `vector`. + */ + @Generated + public static final AzureAISearchQueryType VECTOR = fromString("vector"); + + /** + * Query type `vector_simple_hybrid`. + */ + @Generated + public static final AzureAISearchQueryType VECTOR_SIMPLE_HYBRID = fromString("vector_simple_hybrid"); + + /** + * Query type `vector_semantic_hybrid`. + */ + @Generated + public static final AzureAISearchQueryType VECTOR_SEMANTIC_HYBRID = fromString("vector_semantic_hybrid"); + + /** + * Creates a new instance of AzureAISearchQueryType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public AzureAISearchQueryType() { + } + + /** + * Creates or finds a AzureAISearchQueryType from its string representation. + * + * @param name a name to look for. + * @return the corresponding AzureAISearchQueryType. + */ + @Generated + public static AzureAISearchQueryType fromString(String name) { + return fromString(name, AzureAISearchQueryType.class); + } + + /** + * Gets known AzureAISearchQueryType values. + * + * @return known AzureAISearchQueryType values. + */ + @Generated + public static Collection values() { + return values(AzureAISearchQueryType.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchResource.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchResource.java new file mode 100644 index 000000000000..daad62ebd289 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchResource.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * A set of index resources used by the `azure_ai_search` tool. + */ +@Fluent +public final class AzureAISearchResource implements JsonSerializable { + + /* + * The indices attached to this agent. There can be a maximum of 1 index + * resource attached to the agent. + */ + @Generated + private List indexList; + + /** + * Creates an instance of AzureAISearchResource class. + */ + @Generated + public AzureAISearchResource() { + } + + /** + * Get the indexList property: The indices attached to this agent. There can be a maximum of 1 index + * resource attached to the agent. + * + * @return the indexList value. + */ + @Generated + public List getIndexList() { + return this.indexList; + } + + /** + * Set the indexList property: The indices attached to this agent. There can be a maximum of 1 index + * resource attached to the agent. + * + * @param indexList the indexList value to set. + * @return the AzureAISearchResource object itself. + */ + @Generated + public AzureAISearchResource setIndexList(List indexList) { + this.indexList = indexList; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("indexes", this.indexList, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureAISearchResource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureAISearchResource if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the AzureAISearchResource. + */ + @Generated + public static AzureAISearchResource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AzureAISearchResource deserializedAzureAISearchResource = new AzureAISearchResource(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("indexes".equals(fieldName)) { + List indexList + = reader.readArray(reader1 -> AISearchIndexResource.fromJson(reader1)); + deserializedAzureAISearchResource.indexList = indexList; + } else { + reader.skipChildren(); + } + } + return deserializedAzureAISearchResource; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchToolDefinition.java new file mode 100644 index 000000000000..6b13022bc46b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureAISearchToolDefinition.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for an Azure AI search tool as used to configure an agent. + */ +@Immutable +public final class AzureAISearchToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "azure_ai_search"; + + /** + * Creates an instance of AzureAISearchToolDefinition class. + */ + @Generated + public AzureAISearchToolDefinition() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureAISearchToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureAISearchToolDefinition if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the AzureAISearchToolDefinition. + */ + @Generated + public static AzureAISearchToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AzureAISearchToolDefinition deserializedAzureAISearchToolDefinition = new AzureAISearchToolDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedAzureAISearchToolDefinition.type = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedAzureAISearchToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionBinding.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionBinding.java new file mode 100644 index 000000000000..efd21dcfb3e2 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionBinding.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The structure for keeping storage queue name and URI. + */ +@Immutable +public final class AzureFunctionBinding implements JsonSerializable { + + /* + * The type of binding, which is always 'storage_queue'. + */ + @Generated + private final String type = "storage_queue"; + + /* + * Storage queue. + */ + @Generated + private final AzureFunctionStorageQueue storageQueue; + + /** + * Creates an instance of AzureFunctionBinding class. + * + * @param storageQueue the storageQueue value to set. + */ + @Generated + public AzureFunctionBinding(AzureFunctionStorageQueue storageQueue) { + this.storageQueue = storageQueue; + } + + /** + * Get the type property: The type of binding, which is always 'storage_queue'. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the storageQueue property: Storage queue. + * + * @return the storageQueue value. + */ + @Generated + public AzureFunctionStorageQueue getStorageQueue() { + return this.storageQueue; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("storage_queue", this.storageQueue); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureFunctionBinding from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureFunctionBinding if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureFunctionBinding. + */ + @Generated + public static AzureFunctionBinding fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AzureFunctionStorageQueue storageQueue = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("storage_queue".equals(fieldName)) { + storageQueue = AzureFunctionStorageQueue.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new AzureFunctionBinding(storageQueue); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionDefinition.java new file mode 100644 index 000000000000..15a82f28c9bf --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionDefinition.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The definition of Azure function. + */ +@Immutable +public final class AzureFunctionDefinition implements JsonSerializable { + + /* + * The definition of azure function and its parameters. + */ + @Generated + private final FunctionDefinition function; + + /* + * Input storage queue. The queue storage trigger runs a function as messages are added to it. + */ + @Generated + private final AzureFunctionBinding inputBinding; + + /* + * Output storage queue. The function writes output to this queue when the input items are processed. + */ + @Generated + private final AzureFunctionBinding outputBinding; + + /** + * Creates an instance of AzureFunctionDefinition class. + * + * @param function the function value to set. + * @param inputBinding the inputBinding value to set. + * @param outputBinding the outputBinding value to set. + */ + @Generated + public AzureFunctionDefinition(FunctionDefinition function, AzureFunctionBinding inputBinding, + AzureFunctionBinding outputBinding) { + this.function = function; + this.inputBinding = inputBinding; + this.outputBinding = outputBinding; + } + + /** + * Get the function property: The definition of azure function and its parameters. + * + * @return the function value. + */ + @Generated + public FunctionDefinition getFunction() { + return this.function; + } + + /** + * Get the inputBinding property: Input storage queue. The queue storage trigger runs a function as messages are + * added to it. + * + * @return the inputBinding value. + */ + @Generated + public AzureFunctionBinding getInputBinding() { + return this.inputBinding; + } + + /** + * Get the outputBinding property: Output storage queue. The function writes output to this queue when the input + * items are processed. + * + * @return the outputBinding value. + */ + @Generated + public AzureFunctionBinding getOutputBinding() { + return this.outputBinding; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("function", this.function); + jsonWriter.writeJsonField("input_binding", this.inputBinding); + jsonWriter.writeJsonField("output_binding", this.outputBinding); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureFunctionDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureFunctionDefinition if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureFunctionDefinition. + */ + @Generated + public static AzureFunctionDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FunctionDefinition function = null; + AzureFunctionBinding inputBinding = null; + AzureFunctionBinding outputBinding = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("function".equals(fieldName)) { + function = FunctionDefinition.fromJson(reader); + } else if ("input_binding".equals(fieldName)) { + inputBinding = AzureFunctionBinding.fromJson(reader); + } else if ("output_binding".equals(fieldName)) { + outputBinding = AzureFunctionBinding.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new AzureFunctionDefinition(function, inputBinding, outputBinding); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionStorageQueue.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionStorageQueue.java new file mode 100644 index 000000000000..3a5ad15a4ad9 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionStorageQueue.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The structure for keeping storage queue name and URI. + */ +@Immutable +public final class AzureFunctionStorageQueue implements JsonSerializable { + + /* + * URI to the Azure Storage Queue service allowing you to manipulate a queue. + */ + @Generated + private final String storageServiceEndpoint; + + /* + * The name of an Azure function storage queue. + */ + @Generated + private final String queueName; + + /** + * Creates an instance of AzureFunctionStorageQueue class. + * + * @param storageServiceEndpoint the storageServiceEndpoint value to set. + * @param queueName the queueName value to set. + */ + @Generated + public AzureFunctionStorageQueue(String storageServiceEndpoint, String queueName) { + this.storageServiceEndpoint = storageServiceEndpoint; + this.queueName = queueName; + } + + /** + * Get the storageServiceEndpoint property: URI to the Azure Storage Queue service allowing you to manipulate a + * queue. + * + * @return the storageServiceEndpoint value. + */ + @Generated + public String getStorageServiceEndpoint() { + return this.storageServiceEndpoint; + } + + /** + * Get the queueName property: The name of an Azure function storage queue. + * + * @return the queueName value. + */ + @Generated + public String getQueueName() { + return this.queueName; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("queue_service_endpoint", this.storageServiceEndpoint); + jsonWriter.writeStringField("queue_name", this.queueName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureFunctionStorageQueue from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureFunctionStorageQueue if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureFunctionStorageQueue. + */ + @Generated + public static AzureFunctionStorageQueue fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String storageServiceEndpoint = null; + String queueName = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("queue_service_endpoint".equals(fieldName)) { + storageServiceEndpoint = reader.getString(); + } else if ("queue_name".equals(fieldName)) { + queueName = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new AzureFunctionStorageQueue(storageServiceEndpoint, queueName); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionToolDefinition.java new file mode 100644 index 000000000000..511860899a19 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/AzureFunctionToolDefinition.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for a azure function tool as used to configure an agent. + */ +@Immutable +public final class AzureFunctionToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "azure_function"; + + /* + * The definition of the concrete function that the function tool should call. + */ + @Generated + private final AzureFunctionDefinition azureFunction; + + /** + * Creates an instance of AzureFunctionToolDefinition class. + * + * @param azureFunction the azureFunction value to set. + */ + @Generated + public AzureFunctionToolDefinition(AzureFunctionDefinition azureFunction) { + this.azureFunction = azureFunction; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the azureFunction property: The definition of the concrete function that the function tool should call. + * + * @return the azureFunction value. + */ + @Generated + public AzureFunctionDefinition getAzureFunction() { + return this.azureFunction; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("azure_function", this.azureFunction); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureFunctionToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureFunctionToolDefinition if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureFunctionToolDefinition. + */ + @Generated + public static AzureFunctionToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AzureFunctionDefinition azureFunction = null; + String type = "azure_function"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("azure_function".equals(fieldName)) { + azureFunction = AzureFunctionDefinition.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + AzureFunctionToolDefinition deserializedAzureFunctionToolDefinition + = new AzureFunctionToolDefinition(azureFunction); + deserializedAzureFunctionToolDefinition.type = type; + return deserializedAzureFunctionToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfiguration.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfiguration.java new file mode 100644 index 000000000000..6adbcc0ab48e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfiguration.java @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A bing custom search configuration. + */ +@Fluent +public final class BingCustomSearchConfiguration implements JsonSerializable { + + /* + * Connection id for grounding with bing search + */ + @Generated + private final String connectionId; + + /* + * Name of the custom configuration instance given to config. + */ + @Generated + private final String instanceName; + + /* + * The market where the results come from. + */ + @Generated + private String market; + + /* + * The language to use for user interface strings when calling Bing API. + */ + @Generated + private String setLang; + + /* + * The number of search results to return in the bing api response + */ + @Generated + private Long count; + + /* + * Filter search results by a specific time range. Accepted values: + * https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters + */ + @Generated + private String freshness; + + /** + * Creates an instance of BingCustomSearchConfiguration class. + * + * @param connectionId the connectionId value to set. + * @param instanceName the instanceName value to set. + */ + @Generated + public BingCustomSearchConfiguration(String connectionId, String instanceName) { + this.connectionId = connectionId; + this.instanceName = instanceName; + } + + /** + * Get the connectionId property: Connection id for grounding with bing search. + * + * @return the connectionId value. + */ + @Generated + public String getConnectionId() { + return this.connectionId; + } + + /** + * Get the instanceName property: Name of the custom configuration instance given to config. + * + * @return the instanceName value. + */ + @Generated + public String getInstanceName() { + return this.instanceName; + } + + /** + * Get the market property: The market where the results come from. + * + * @return the market value. + */ + @Generated + public String getMarket() { + return this.market; + } + + /** + * Set the market property: The market where the results come from. + * + * @param market the market value to set. + * @return the BingCustomSearchConfiguration object itself. + */ + @Generated + public BingCustomSearchConfiguration setMarket(String market) { + this.market = market; + return this; + } + + /** + * Get the setLang property: The language to use for user interface strings when calling Bing API. + * + * @return the setLang value. + */ + @Generated + public String getSetLang() { + return this.setLang; + } + + /** + * Set the setLang property: The language to use for user interface strings when calling Bing API. + * + * @param setLang the setLang value to set. + * @return the BingCustomSearchConfiguration object itself. + */ + @Generated + public BingCustomSearchConfiguration setSetLang(String setLang) { + this.setLang = setLang; + return this; + } + + /** + * Get the count property: The number of search results to return in the bing api response. + * + * @return the count value. + */ + @Generated + public Long getCount() { + return this.count; + } + + /** + * Set the count property: The number of search results to return in the bing api response. + * + * @param count the count value to set. + * @return the BingCustomSearchConfiguration object itself. + */ + @Generated + public BingCustomSearchConfiguration setCount(Long count) { + this.count = count; + return this; + } + + /** + * Get the freshness property: Filter search results by a specific time range. Accepted values: + * https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters. + * + * @return the freshness value. + */ + @Generated + public String getFreshness() { + return this.freshness; + } + + /** + * Set the freshness property: Filter search results by a specific time range. Accepted values: + * https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters. + * + * @param freshness the freshness value to set. + * @return the BingCustomSearchConfiguration object itself. + */ + @Generated + public BingCustomSearchConfiguration setFreshness(String freshness) { + this.freshness = freshness; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("connection_id", this.connectionId); + jsonWriter.writeStringField("instance_name", this.instanceName); + jsonWriter.writeStringField("market", this.market); + jsonWriter.writeStringField("set_lang", this.setLang); + jsonWriter.writeNumberField("count", this.count); + jsonWriter.writeStringField("freshness", this.freshness); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BingCustomSearchConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BingCustomSearchConfiguration if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BingCustomSearchConfiguration. + */ + @Generated + public static BingCustomSearchConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String connectionId = null; + String instanceName = null; + String market = null; + String setLang = null; + Long count = null; + String freshness = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("connection_id".equals(fieldName)) { + connectionId = reader.getString(); + } else if ("instance_name".equals(fieldName)) { + instanceName = reader.getString(); + } else if ("market".equals(fieldName)) { + market = reader.getString(); + } else if ("set_lang".equals(fieldName)) { + setLang = reader.getString(); + } else if ("count".equals(fieldName)) { + count = reader.getNullable(JsonReader::getLong); + } else if ("freshness".equals(fieldName)) { + freshness = reader.getString(); + } else { + reader.skipChildren(); + } + } + BingCustomSearchConfiguration deserializedBingCustomSearchConfiguration + = new BingCustomSearchConfiguration(connectionId, instanceName); + deserializedBingCustomSearchConfiguration.market = market; + deserializedBingCustomSearchConfiguration.setLang = setLang; + deserializedBingCustomSearchConfiguration.count = count; + deserializedBingCustomSearchConfiguration.freshness = freshness; + return deserializedBingCustomSearchConfiguration; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfigurationList.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfigurationList.java new file mode 100644 index 000000000000..558c304c215d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfigurationList.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * A list of search configurations currently used by the `bing_custom_search` tool. + */ +@Immutable +public final class BingCustomSearchConfigurationList implements JsonSerializable { + + /* + * The connections attached to this tool. There can be a maximum of 1 connection + * resource attached to the tool. + */ + @Generated + private final List searchConfigurations; + + /** + * Creates an instance of BingCustomSearchConfigurationList class. + * + * @param searchConfigurations the searchConfigurations value to set. + */ + @Generated + public BingCustomSearchConfigurationList(List searchConfigurations) { + this.searchConfigurations = searchConfigurations; + } + + /** + * Get the searchConfigurations property: The connections attached to this tool. There can be a maximum of 1 + * connection + * resource attached to the tool. + * + * @return the searchConfigurations value. + */ + @Generated + public List getSearchConfigurations() { + return this.searchConfigurations; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("search_configurations", this.searchConfigurations, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BingCustomSearchConfigurationList from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BingCustomSearchConfigurationList if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BingCustomSearchConfigurationList. + */ + @Generated + public static BingCustomSearchConfigurationList fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List searchConfigurations = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("search_configurations".equals(fieldName)) { + searchConfigurations = reader.readArray(reader1 -> BingCustomSearchConfiguration.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new BingCustomSearchConfigurationList(searchConfigurations); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchToolDefinition.java new file mode 100644 index 000000000000..38421231f5ed --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchToolDefinition.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for a Bing custom search tool as used to configure an agent. + */ +@Immutable +public final class BingCustomSearchToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "bing_custom_search"; + + /* + * The list of search configurations used by the bing custom search tool. + */ + @Generated + private final BingCustomSearchConfigurationList bingCustomSearch; + + /** + * Creates an instance of BingCustomSearchToolDefinition class. + * + * @param bingCustomSearch the bingCustomSearch value to set. + */ + @Generated + public BingCustomSearchToolDefinition(BingCustomSearchConfigurationList bingCustomSearch) { + this.bingCustomSearch = bingCustomSearch; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the bingCustomSearch property: The list of search configurations used by the bing custom search tool. + * + * @return the bingCustomSearch value. + */ + @Generated + public BingCustomSearchConfigurationList getBingCustomSearch() { + return this.bingCustomSearch; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("bing_custom_search", this.bingCustomSearch); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BingCustomSearchToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BingCustomSearchToolDefinition if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BingCustomSearchToolDefinition. + */ + @Generated + public static BingCustomSearchToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BingCustomSearchConfigurationList bingCustomSearch = null; + String type = "bing_custom_search"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("bing_custom_search".equals(fieldName)) { + bingCustomSearch = BingCustomSearchConfigurationList.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + BingCustomSearchToolDefinition deserializedBingCustomSearchToolDefinition + = new BingCustomSearchToolDefinition(bingCustomSearch); + deserializedBingCustomSearchToolDefinition.type = type; + return deserializedBingCustomSearchToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingSearchConfiguration.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingSearchConfiguration.java new file mode 100644 index 000000000000..639e1b97f882 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingSearchConfiguration.java @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Search configuration for Bing Grounding. + */ +@Fluent +public final class BingGroundingSearchConfiguration implements JsonSerializable { + + /* + * Connection id for grounding with bing search + */ + @Generated + private final String connectionId; + + /* + * The market where the results come from. + */ + @Generated + private String market; + + /* + * The language to use for user interface strings when calling Bing API. + */ + @Generated + private String setLang; + + /* + * The number of search results to return in the bing api response + */ + @Generated + private Long count; + + /* + * Filter search results by a specific time range. Accepted values: + * https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters + */ + @Generated + private String freshness; + + /** + * Creates an instance of BingGroundingSearchConfiguration class. + * + * @param connectionId the connectionId value to set. + */ + @Generated + public BingGroundingSearchConfiguration(String connectionId) { + this.connectionId = connectionId; + } + + /** + * Get the connectionId property: Connection id for grounding with bing search. + * + * @return the connectionId value. + */ + @Generated + public String getConnectionId() { + return this.connectionId; + } + + /** + * Get the market property: The market where the results come from. + * + * @return the market value. + */ + @Generated + public String getMarket() { + return this.market; + } + + /** + * Set the market property: The market where the results come from. + * + * @param market the market value to set. + * @return the BingGroundingSearchConfiguration object itself. + */ + @Generated + public BingGroundingSearchConfiguration setMarket(String market) { + this.market = market; + return this; + } + + /** + * Get the setLang property: The language to use for user interface strings when calling Bing API. + * + * @return the setLang value. + */ + @Generated + public String getSetLang() { + return this.setLang; + } + + /** + * Set the setLang property: The language to use for user interface strings when calling Bing API. + * + * @param setLang the setLang value to set. + * @return the BingGroundingSearchConfiguration object itself. + */ + @Generated + public BingGroundingSearchConfiguration setSetLang(String setLang) { + this.setLang = setLang; + return this; + } + + /** + * Get the count property: The number of search results to return in the bing api response. + * + * @return the count value. + */ + @Generated + public Long getCount() { + return this.count; + } + + /** + * Set the count property: The number of search results to return in the bing api response. + * + * @param count the count value to set. + * @return the BingGroundingSearchConfiguration object itself. + */ + @Generated + public BingGroundingSearchConfiguration setCount(Long count) { + this.count = count; + return this; + } + + /** + * Get the freshness property: Filter search results by a specific time range. Accepted values: + * https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters. + * + * @return the freshness value. + */ + @Generated + public String getFreshness() { + return this.freshness; + } + + /** + * Set the freshness property: Filter search results by a specific time range. Accepted values: + * https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters. + * + * @param freshness the freshness value to set. + * @return the BingGroundingSearchConfiguration object itself. + */ + @Generated + public BingGroundingSearchConfiguration setFreshness(String freshness) { + this.freshness = freshness; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("connection_id", this.connectionId); + jsonWriter.writeStringField("market", this.market); + jsonWriter.writeStringField("set_lang", this.setLang); + jsonWriter.writeNumberField("count", this.count); + jsonWriter.writeStringField("freshness", this.freshness); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BingGroundingSearchConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BingGroundingSearchConfiguration if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BingGroundingSearchConfiguration. + */ + @Generated + public static BingGroundingSearchConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String connectionId = null; + String market = null; + String setLang = null; + Long count = null; + String freshness = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("connection_id".equals(fieldName)) { + connectionId = reader.getString(); + } else if ("market".equals(fieldName)) { + market = reader.getString(); + } else if ("set_lang".equals(fieldName)) { + setLang = reader.getString(); + } else if ("count".equals(fieldName)) { + count = reader.getNullable(JsonReader::getLong); + } else if ("freshness".equals(fieldName)) { + freshness = reader.getString(); + } else { + reader.skipChildren(); + } + } + BingGroundingSearchConfiguration deserializedBingGroundingSearchConfiguration + = new BingGroundingSearchConfiguration(connectionId); + deserializedBingGroundingSearchConfiguration.market = market; + deserializedBingGroundingSearchConfiguration.setLang = setLang; + deserializedBingGroundingSearchConfiguration.count = count; + deserializedBingGroundingSearchConfiguration.freshness = freshness; + return deserializedBingGroundingSearchConfiguration; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingSearchConfigurationList.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingSearchConfigurationList.java new file mode 100644 index 000000000000..01800dd08493 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingSearchConfigurationList.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * A list of search configurations currently used by the `bing_grounding` tool. + */ +@Immutable +public final class BingGroundingSearchConfigurationList + implements JsonSerializable { + + /* + * The search configurations attached to this tool. There can be a maximum of 1 + * search configuration resource attached to the tool. + */ + @Generated + private final List searchConfigurations; + + /** + * Creates an instance of BingGroundingSearchConfigurationList class. + * + * @param searchConfigurations the searchConfigurations value to set. + */ + @Generated + public BingGroundingSearchConfigurationList(List searchConfigurations) { + this.searchConfigurations = searchConfigurations; + } + + /** + * Get the searchConfigurations property: The search configurations attached to this tool. There can be a maximum of + * 1 + * search configuration resource attached to the tool. + * + * @return the searchConfigurations value. + */ + @Generated + public List getSearchConfigurations() { + return this.searchConfigurations; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("search_configurations", this.searchConfigurations, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BingGroundingSearchConfigurationList from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BingGroundingSearchConfigurationList if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BingGroundingSearchConfigurationList. + */ + @Generated + public static BingGroundingSearchConfigurationList fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List searchConfigurations = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("search_configurations".equals(fieldName)) { + searchConfigurations + = reader.readArray(reader1 -> BingGroundingSearchConfiguration.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new BingGroundingSearchConfigurationList(searchConfigurations); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingToolDefinition.java new file mode 100644 index 000000000000..d55add499d96 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingGroundingToolDefinition.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for a bing grounding search tool as used to configure an agent. + */ +@Immutable +public final class BingGroundingToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "bing_grounding"; + + /* + * The list of search configurations used by the bing grounding tool. + */ + @Generated + private final BingGroundingSearchConfigurationList bingGrounding; + + /** + * Creates an instance of BingGroundingToolDefinition class. + * + * @param bingGrounding the bingGrounding value to set. + */ + @Generated + public BingGroundingToolDefinition(BingGroundingSearchConfigurationList bingGrounding) { + this.bingGrounding = bingGrounding; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the bingGrounding property: The list of search configurations used by the bing grounding tool. + * + * @return the bingGrounding value. + */ + @Generated + public BingGroundingSearchConfigurationList getBingGrounding() { + return this.bingGrounding; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("bing_grounding", this.bingGrounding); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BingGroundingToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BingGroundingToolDefinition if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BingGroundingToolDefinition. + */ + @Generated + public static BingGroundingToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BingGroundingSearchConfigurationList bingGrounding = null; + String type = "bing_grounding"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("bing_grounding".equals(fieldName)) { + bingGrounding = BingGroundingSearchConfigurationList.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + BingGroundingToolDefinition deserializedBingGroundingToolDefinition + = new BingGroundingToolDefinition(bingGrounding); + deserializedBingGroundingToolDefinition.type = type; + return deserializedBingGroundingToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CodeInterpreterToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CodeInterpreterToolDefinition.java new file mode 100644 index 000000000000..e2914963ec47 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CodeInterpreterToolDefinition.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for a code interpreter tool as used to configure an agent. + */ +@Immutable +public final class CodeInterpreterToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "code_interpreter"; + + /** + * Creates an instance of CodeInterpreterToolDefinition class. + */ + @Generated + public CodeInterpreterToolDefinition() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CodeInterpreterToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CodeInterpreterToolDefinition if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the CodeInterpreterToolDefinition. + */ + @Generated + public static CodeInterpreterToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CodeInterpreterToolDefinition deserializedCodeInterpreterToolDefinition + = new CodeInterpreterToolDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedCodeInterpreterToolDefinition.type = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedCodeInterpreterToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CodeInterpreterToolResource.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CodeInterpreterToolResource.java new file mode 100644 index 000000000000..c1928ad6af79 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CodeInterpreterToolResource.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * A set of resources that are used by the `code_interpreter` tool. + */ +@Fluent +public final class CodeInterpreterToolResource implements JsonSerializable { + + /* + * A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + * associated with the tool. + */ + @Generated + private List fileIds; + + /* + * The data sources to be used. This option is mutually exclusive with the `fileIds` property. + */ + @Generated + private List dataSources; + + /** + * Creates an instance of CodeInterpreterToolResource class. + */ + @Generated + public CodeInterpreterToolResource() { + } + + /** + * Get the fileIds property: A list of file IDs made available to the `code_interpreter` tool. There can be a + * maximum of 20 files + * associated with the tool. + * + * @return the fileIds value. + */ + @Generated + public List getFileIds() { + return this.fileIds; + } + + /** + * Set the fileIds property: A list of file IDs made available to the `code_interpreter` tool. There can be a + * maximum of 20 files + * associated with the tool. + * + * @param fileIds the fileIds value to set. + * @return the CodeInterpreterToolResource object itself. + */ + @Generated + public CodeInterpreterToolResource setFileIds(List fileIds) { + this.fileIds = fileIds; + return this; + } + + /** + * Get the dataSources property: The data sources to be used. This option is mutually exclusive with the `fileIds` + * property. + * + * @return the dataSources value. + */ + @Generated + public List getDataSources() { + return this.dataSources; + } + + /** + * Set the dataSources property: The data sources to be used. This option is mutually exclusive with the `fileIds` + * property. + * + * @param dataSources the dataSources value to set. + * @return the CodeInterpreterToolResource object itself. + */ + @Generated + public CodeInterpreterToolResource setDataSources(List dataSources) { + this.dataSources = dataSources; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("file_ids", this.fileIds, (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("data_sources", this.dataSources, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CodeInterpreterToolResource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CodeInterpreterToolResource if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the CodeInterpreterToolResource. + */ + @Generated + public static CodeInterpreterToolResource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CodeInterpreterToolResource deserializedCodeInterpreterToolResource = new CodeInterpreterToolResource(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_ids".equals(fieldName)) { + List fileIds = reader.readArray(reader1 -> reader1.getString()); + deserializedCodeInterpreterToolResource.fileIds = fileIds; + } else if ("data_sources".equals(fieldName)) { + List dataSources + = reader.readArray(reader1 -> VectorStoreDataSource.fromJson(reader1)); + deserializedCodeInterpreterToolResource.dataSources = dataSources; + } else { + reader.skipChildren(); + } + } + return deserializedCodeInterpreterToolResource; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ConnectedAgentDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ConnectedAgentDetails.java new file mode 100644 index 000000000000..f318193291b7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ConnectedAgentDetails.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Information for connecting one agent to another as a tool. + */ +@Immutable +public final class ConnectedAgentDetails implements JsonSerializable { + + /* + * The identifier of the child agent. + */ + @Generated + private final String id; + + /* + * The name of the agent to be called. + */ + @Generated + private final String name; + + /* + * A description of what the agent does, used by the model to choose when and how to call the agent. + */ + @Generated + private final String description; + + /** + * Creates an instance of ConnectedAgentDetails class. + * + * @param id the id value to set. + * @param name the name value to set. + * @param description the description value to set. + */ + @Generated + public ConnectedAgentDetails(String id, String name, String description) { + this.id = id; + this.name = name; + this.description = description; + } + + /** + * Get the id property: The identifier of the child agent. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name of the agent to be called. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the description property: A description of what the agent does, used by the model to choose when and how to + * call the agent. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ConnectedAgentDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ConnectedAgentDetails if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ConnectedAgentDetails. + */ + @Generated + public static ConnectedAgentDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + String description = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ConnectedAgentDetails(id, name, description); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ConnectedAgentToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ConnectedAgentToolDefinition.java new file mode 100644 index 000000000000..bf5f0fbc16f8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ConnectedAgentToolDefinition.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for a connected agent tool which defines a domain specific sub-agent. + */ +@Immutable +public final class ConnectedAgentToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "connected_agent"; + + /* + * The sub-agent to connect + */ + @Generated + private final ConnectedAgentDetails connectedAgent; + + /** + * Creates an instance of ConnectedAgentToolDefinition class. + * + * @param connectedAgent the connectedAgent value to set. + */ + @Generated + public ConnectedAgentToolDefinition(ConnectedAgentDetails connectedAgent) { + this.connectedAgent = connectedAgent; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the connectedAgent property: The sub-agent to connect. + * + * @return the connectedAgent value. + */ + @Generated + public ConnectedAgentDetails getConnectedAgent() { + return this.connectedAgent; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("connected_agent", this.connectedAgent); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ConnectedAgentToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ConnectedAgentToolDefinition if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ConnectedAgentToolDefinition. + */ + @Generated + public static ConnectedAgentToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ConnectedAgentDetails connectedAgent = null; + String type = "connected_agent"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("connected_agent".equals(fieldName)) { + connectedAgent = ConnectedAgentDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + ConnectedAgentToolDefinition deserializedConnectedAgentToolDefinition + = new ConnectedAgentToolDefinition(connectedAgent); + deserializedConnectedAgentToolDefinition.type = type; + return deserializedConnectedAgentToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateAgentOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateAgentOptions.java new file mode 100644 index 000000000000..507d290a5e78 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateAgentOptions.java @@ -0,0 +1,324 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import java.util.List; +import java.util.Map; + +/** + * Options for createAgent API. + */ +@Fluent +public final class CreateAgentOptions { + + /* + * The ID of the model to use. + */ + @Generated + private final String model; + + /* + * The name of the new agent. + */ + @Generated + private String name; + + /* + * The description of the new agent. + */ + @Generated + private String description; + + /* + * The system instructions for the new agent to use. + */ + @Generated + private String instructions; + + /* + * The collection of tools to enable for the new agent. + */ + @Generated + private List tools; + + /* + * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For + * example, the `code_interpreter` + * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + */ + @Generated + private ToolResources toolResources; + + /* + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + */ + @Generated + private Double temperature; + + /* + * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of + * the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + */ + @Generated + private Double topP; + + /* + * The response format of the tool calls used by this agent. + */ + @Generated + private BinaryData responseFormat; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of CreateAgentOptions class. + * + * @param model the model value to set. + */ + @Generated + public CreateAgentOptions(String model) { + this.model = model; + } + + /** + * Get the model property: The ID of the model to use. + * + * @return the model value. + */ + @Generated + public String getModel() { + return this.model; + } + + /** + * Get the name property: The name of the new agent. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The name of the new agent. + * + * @param name the name value to set. + * @return the CreateAgentOptions object itself. + */ + @Generated + public CreateAgentOptions setName(String name) { + this.name = name; + return this; + } + + /** + * Get the description property: The description of the new agent. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description of the new agent. + * + * @param description the description value to set. + * @return the CreateAgentOptions object itself. + */ + @Generated + public CreateAgentOptions setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the instructions property: The system instructions for the new agent to use. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Set the instructions property: The system instructions for the new agent to use. + * + * @param instructions the instructions value to set. + * @return the CreateAgentOptions object itself. + */ + @Generated + public CreateAgentOptions setInstructions(String instructions) { + this.instructions = instructions; + return this; + } + + /** + * Get the tools property: The collection of tools to enable for the new agent. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * Set the tools property: The collection of tools to enable for the new agent. + * + * @param tools the tools value to set. + * @return the CreateAgentOptions object itself. + */ + @Generated + public CreateAgentOptions setTools(List tools) { + this.tools = tools; + return this; + } + + /** + * Get the toolResources property: A set of resources that are used by the agent's tools. The resources are specific + * to the type of tool. For example, the `code_interpreter` + * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * + * @return the toolResources value. + */ + @Generated + public ToolResources getToolResources() { + return this.toolResources; + } + + /** + * Set the toolResources property: A set of resources that are used by the agent's tools. The resources are specific + * to the type of tool. For example, the `code_interpreter` + * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * + * @param toolResources the toolResources value to set. + * @return the CreateAgentOptions object itself. + */ + @Generated + public CreateAgentOptions setToolResources(ToolResources toolResources) { + this.toolResources = toolResources; + return this; + } + + /** + * Get the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + * + * @return the temperature value. + */ + @Generated + public Double getTemperature() { + return this.temperature; + } + + /** + * Set the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + * + * @param temperature the temperature value to set. + * @return the CreateAgentOptions object itself. + */ + @Generated + public CreateAgentOptions setTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + /** + * Get the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @return the topP value. + */ + @Generated + public Double getTopP() { + return this.topP; + } + + /** + * Set the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @param topP the topP value to set. + * @return the CreateAgentOptions object itself. + */ + @Generated + public CreateAgentOptions setTopP(Double topP) { + this.topP = topP; + return this; + } + + /** + * Get the responseFormat property: The response format of the tool calls used by this agent. + * + * @return the responseFormat value. + */ + @Generated + public BinaryData getResponseFormat() { + return this.responseFormat; + } + + /** + * Set the responseFormat property: The response format of the tool calls used by this agent. + * + * @param responseFormat the responseFormat value to set. + * @return the CreateAgentOptions object itself. + */ + @Generated + public CreateAgentOptions setResponseFormat(BinaryData responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the CreateAgentOptions object itself. + */ + @Generated + public CreateAgentOptions setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateRunOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateRunOptions.java new file mode 100644 index 000000000000..405c45ea3c61 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateRunOptions.java @@ -0,0 +1,573 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import java.util.List; +import java.util.Map; + +/** + * Options for createRun API. + */ +@Fluent +public final class CreateRunOptions { + + /* + * Identifier of the thread. + */ + @Generated + private final String threadId; + + /* + * A list of additional fields to include in the response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + * to fetch the file search result content. + */ + @Generated + private List include; + + /* + * The ID of the agent that should run the thread. + */ + @Generated + private final String assistantId; + + /* + * The overridden model name that the agent should use to run the thread. + */ + @Generated + private String model; + + /* + * The overridden system instructions that the agent should use to run the thread. + */ + @Generated + private String instructions; + + /* + * 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. + */ + @Generated + private String additionalInstructions; + + /* + * Adds additional messages to the thread before creating the run. + */ + @Generated + private List additionalMessages; + + /* + * The overridden list of enabled tools that the agent should use to run the thread. + */ + @Generated + private List tools; + + /* + * If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + */ + @Generated + private Boolean stream; + + /* + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + */ + @Generated + private Double temperature; + + /* + * An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + */ + @Generated + private Double topP; + + /* + * The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort + * to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + */ + @Generated + private Integer maxPromptTokens; + + /* + * The maximum number of completion tokens that may be used over the course of the run. The run will make a best + * effort + * to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the + * number of + * completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + */ + @Generated + private Integer maxCompletionTokens; + + /* + * The strategy to use for dropping messages as the context windows moves forward. + */ + @Generated + private TruncationObject truncationStrategy; + + /* + * Controls whether or not and which tool is called by the model. + */ + @Generated + private BinaryData toolChoice; + + /* + * Specifies the format that the model must output. + */ + @Generated + private BinaryData responseFormat; + + /* + * If `true` functions will run in parallel during tool use. + */ + @Generated + private Boolean parallelToolCalls; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of CreateRunOptions class. + * + * @param threadId the threadId value to set. + * @param assistantId the assistantId value to set. + */ + @Generated + public CreateRunOptions(String threadId, String assistantId) { + this.threadId = threadId; + this.assistantId = assistantId; + } + + /** + * Get the threadId property: Identifier of the thread. + * + * @return the threadId value. + */ + @Generated + public String getThreadId() { + return this.threadId; + } + + /** + * Get the include property: A list of additional fields to include in the response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + * to fetch the file search result content. + * + * @return the include value. + */ + @Generated + public List getInclude() { + return this.include; + } + + /** + * Set the include property: A list of additional fields to include in the response. + * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` + * to fetch the file search result content. + * + * @param include the include value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setInclude(List include) { + this.include = include; + return this; + } + + /** + * Get the assistantId property: The ID of the agent that should run the thread. + * + * @return the assistantId value. + */ + @Generated + public String getAssistantId() { + return this.assistantId; + } + + /** + * Get the model property: The overridden model name that the agent should use to run the thread. + * + * @return the model value. + */ + @Generated + public String getModel() { + return this.model; + } + + /** + * Set the model property: The overridden model name that the agent should use to run the thread. + * + * @param model the model value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setModel(String model) { + this.model = model; + return this; + } + + /** + * Get the instructions property: The overridden system instructions that the agent should use to run the thread. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Set the instructions property: The overridden system instructions that the agent should use to run the thread. + * + * @param instructions the instructions value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setInstructions(String instructions) { + this.instructions = instructions; + return this; + } + + /** + * Get the additionalInstructions property: 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. + * + * @return the additionalInstructions value. + */ + @Generated + public String getAdditionalInstructions() { + return this.additionalInstructions; + } + + /** + * Set the additionalInstructions property: 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. + * + * @param additionalInstructions the additionalInstructions value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setAdditionalInstructions(String additionalInstructions) { + this.additionalInstructions = additionalInstructions; + return this; + } + + /** + * Get the additionalMessages property: Adds additional messages to the thread before creating the run. + * + * @return the additionalMessages value. + */ + @Generated + public List getAdditionalMessages() { + return this.additionalMessages; + } + + /** + * Set the additionalMessages property: Adds additional messages to the thread before creating the run. + * + * @param additionalMessages the additionalMessages value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setAdditionalMessages(List additionalMessages) { + this.additionalMessages = additionalMessages; + return this; + } + + /** + * Get the tools property: The overridden list of enabled tools that the agent should use to run the thread. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * Set the tools property: The overridden list of enabled tools that the agent should use to run the thread. + * + * @param tools the tools value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setTools(List tools) { + this.tools = tools; + return this; + } + + /** + * Get the stream property: If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + * + * @return the stream value. + */ + @Generated + public Boolean isStream() { + return this.stream; + } + + /** + * Set the stream property: If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + * + * @param stream the stream value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setStream(Boolean stream) { + this.stream = stream; + return this; + } + + /** + * Get the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @return the temperature value. + */ + @Generated + public Double getTemperature() { + return this.temperature; + } + + /** + * Set the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @param temperature the temperature value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + /** + * Get the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @return the topP value. + */ + @Generated + public Double getTopP() { + return this.topP; + } + + /** + * Set the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @param topP the topP value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setTopP(Double topP) { + this.topP = topP; + return this; + } + + /** + * Get the maxPromptTokens property: The maximum number of prompt tokens that may be used over the course of the + * run. The run will make a best effort to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @return the maxPromptTokens value. + */ + @Generated + public Integer getMaxPromptTokens() { + return this.maxPromptTokens; + } + + /** + * Set the maxPromptTokens property: The maximum number of prompt tokens that may be used over the course of the + * run. The run will make a best effort to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @param maxPromptTokens the maxPromptTokens value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setMaxPromptTokens(Integer maxPromptTokens) { + this.maxPromptTokens = maxPromptTokens; + return this; + } + + /** + * Get the maxCompletionTokens property: The maximum number of completion tokens that may be used over the course of + * the run. The run will make a best effort + * to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the + * number of + * completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @return the maxCompletionTokens value. + */ + @Generated + public Integer getMaxCompletionTokens() { + return this.maxCompletionTokens; + } + + /** + * Set the maxCompletionTokens property: The maximum number of completion tokens that may be used over the course of + * the run. The run will make a best effort + * to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the + * number of + * completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @param maxCompletionTokens the maxCompletionTokens value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setMaxCompletionTokens(Integer maxCompletionTokens) { + this.maxCompletionTokens = maxCompletionTokens; + return this; + } + + /** + * Get the truncationStrategy property: The strategy to use for dropping messages as the context windows moves + * forward. + * + * @return the truncationStrategy value. + */ + @Generated + public TruncationObject getTruncationStrategy() { + return this.truncationStrategy; + } + + /** + * Set the truncationStrategy property: The strategy to use for dropping messages as the context windows moves + * forward. + * + * @param truncationStrategy the truncationStrategy value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setTruncationStrategy(TruncationObject truncationStrategy) { + this.truncationStrategy = truncationStrategy; + return this; + } + + /** + * Get the toolChoice property: Controls whether or not and which tool is called by the model. + * + * @return the toolChoice value. + */ + @Generated + public BinaryData getToolChoice() { + return this.toolChoice; + } + + /** + * Set the toolChoice property: Controls whether or not and which tool is called by the model. + * + * @param toolChoice the toolChoice value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setToolChoice(BinaryData toolChoice) { + this.toolChoice = toolChoice; + return this; + } + + /** + * Get the responseFormat property: Specifies the format that the model must output. + * + * @return the responseFormat value. + */ + @Generated + public BinaryData getResponseFormat() { + return this.responseFormat; + } + + /** + * Set the responseFormat property: Specifies the format that the model must output. + * + * @param responseFormat the responseFormat value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setResponseFormat(BinaryData responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * Get the parallelToolCalls property: If `true` functions will run in parallel during tool use. + * + * @return the parallelToolCalls value. + */ + @Generated + public Boolean isParallelToolCalls() { + return this.parallelToolCalls; + } + + /** + * Set the parallelToolCalls property: If `true` functions will run in parallel during tool use. + * + * @param parallelToolCalls the parallelToolCalls value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setParallelToolCalls(Boolean parallelToolCalls) { + this.parallelToolCalls = parallelToolCalls; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the CreateRunOptions object itself. + */ + @Generated + public CreateRunOptions setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateThreadAndRunOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateThreadAndRunOptions.java new file mode 100644 index 000000000000..3e4fa0016ef7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/CreateThreadAndRunOptions.java @@ -0,0 +1,519 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import java.util.List; +import java.util.Map; + +/** + * Options for createThreadAndRun API. + */ +@Fluent +public final class CreateThreadAndRunOptions { + + /* + * The ID of the agent for which the thread should be created. + */ + @Generated + private final String assistantId; + + /* + * The details used to create the new thread. If no thread is provided, an empty one will be created. + */ + @Generated + private PersistentAgentThreadCreationOptions thread; + + /* + * The overridden model that the agent should use to run the thread. + */ + @Generated + private String model; + + /* + * The overridden system instructions the agent should use to run the thread. + */ + @Generated + private String instructions; + + /* + * The overridden list of enabled tools the agent should use to run the thread. + */ + @Generated + private List tools; + + /* + * Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis + */ + @Generated + private UpdateToolResourcesOptions toolResources; + + /* + * If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + */ + @Generated + private Boolean stream; + + /* + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + */ + @Generated + private Double temperature; + + /* + * An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + */ + @Generated + private Double topP; + + /* + * The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort + * to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + */ + @Generated + private Integer maxPromptTokens; + + /* + * The maximum number of completion tokens that may be used over the course of the run. The run will make a best + * effort to use only + * the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + * completion tokens + * specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + */ + @Generated + private Integer maxCompletionTokens; + + /* + * The strategy to use for dropping messages as the context windows moves forward. + */ + @Generated + private TruncationObject truncationStrategy; + + /* + * Controls whether or not and which tool is called by the model. + */ + @Generated + private BinaryData toolChoice; + + /* + * Specifies the format that the model must output. + */ + @Generated + private BinaryData responseFormat; + + /* + * If `true` functions will run in parallel during tool use. + */ + @Generated + private Boolean parallelToolCalls; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of CreateThreadAndRunOptions class. + * + * @param assistantId the assistantId value to set. + */ + @Generated + public CreateThreadAndRunOptions(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Get the assistantId property: The ID of the agent for which the thread should be created. + * + * @return the assistantId value. + */ + @Generated + public String getAssistantId() { + return this.assistantId; + } + + /** + * Get the thread property: The details used to create the new thread. If no thread is provided, an empty one will + * be created. + * + * @return the thread value. + */ + @Generated + public PersistentAgentThreadCreationOptions getThread() { + return this.thread; + } + + /** + * Set the thread property: The details used to create the new thread. If no thread is provided, an empty one will + * be created. + * + * @param thread the thread value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setThread(PersistentAgentThreadCreationOptions thread) { + this.thread = thread; + return this; + } + + /** + * Get the model property: The overridden model that the agent should use to run the thread. + * + * @return the model value. + */ + @Generated + public String getModel() { + return this.model; + } + + /** + * Set the model property: The overridden model that the agent should use to run the thread. + * + * @param model the model value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setModel(String model) { + this.model = model; + return this; + } + + /** + * Get the instructions property: The overridden system instructions the agent should use to run the thread. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Set the instructions property: The overridden system instructions the agent should use to run the thread. + * + * @param instructions the instructions value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setInstructions(String instructions) { + this.instructions = instructions; + return this; + } + + /** + * Get the tools property: The overridden list of enabled tools the agent should use to run the thread. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * Set the tools property: The overridden list of enabled tools the agent should use to run the thread. + * + * @param tools the tools value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setTools(List tools) { + this.tools = tools; + return this; + } + + /** + * Get the toolResources property: Override the tools the agent can use for this run. This is useful for modifying + * the behavior on a per-run basis. + * + * @return the toolResources value. + */ + @Generated + public UpdateToolResourcesOptions getToolResources() { + return this.toolResources; + } + + /** + * Set the toolResources property: Override the tools the agent can use for this run. This is useful for modifying + * the behavior on a per-run basis. + * + * @param toolResources the toolResources value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setToolResources(UpdateToolResourcesOptions toolResources) { + this.toolResources = toolResources; + return this; + } + + /** + * Get the stream property: If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + * + * @return the stream value. + */ + @Generated + public Boolean isStream() { + return this.stream; + } + + /** + * Set the stream property: If `true`, returns a stream of events that happen during the Run as server-sent events, + * terminating when the Run enters a terminal state with a `data: [DONE]` message. + * + * @param stream the stream value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setStream(Boolean stream) { + this.stream = stream; + return this; + } + + /** + * Get the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @return the temperature value. + */ + @Generated + public Double getTemperature() { + return this.temperature; + } + + /** + * Set the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output + * more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @param temperature the temperature value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + /** + * Get the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @return the topP value. + */ + @Generated + public Double getTopP() { + return this.topP; + } + + /** + * Set the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + * comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @param topP the topP value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setTopP(Double topP) { + this.topP = topP; + return this; + } + + /** + * Get the maxPromptTokens property: The maximum number of prompt tokens that may be used over the course of the + * run. The run will make a best effort to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @return the maxPromptTokens value. + */ + @Generated + public Integer getMaxPromptTokens() { + return this.maxPromptTokens; + } + + /** + * Set the maxPromptTokens property: The maximum number of prompt tokens that may be used over the course of the + * run. The run will make a best effort to use only + * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt + * tokens specified, + * the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @param maxPromptTokens the maxPromptTokens value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setMaxPromptTokens(Integer maxPromptTokens) { + this.maxPromptTokens = maxPromptTokens; + return this; + } + + /** + * Get the maxCompletionTokens property: The maximum number of completion tokens that may be used over the course of + * the run. The run will make a best effort to use only + * the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + * completion tokens + * specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @return the maxCompletionTokens value. + */ + @Generated + public Integer getMaxCompletionTokens() { + return this.maxCompletionTokens; + } + + /** + * Set the maxCompletionTokens property: The maximum number of completion tokens that may be used over the course of + * the run. The run will make a best effort to use only + * the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + * completion tokens + * specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * + * @param maxCompletionTokens the maxCompletionTokens value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setMaxCompletionTokens(Integer maxCompletionTokens) { + this.maxCompletionTokens = maxCompletionTokens; + return this; + } + + /** + * Get the truncationStrategy property: The strategy to use for dropping messages as the context windows moves + * forward. + * + * @return the truncationStrategy value. + */ + @Generated + public TruncationObject getTruncationStrategy() { + return this.truncationStrategy; + } + + /** + * Set the truncationStrategy property: The strategy to use for dropping messages as the context windows moves + * forward. + * + * @param truncationStrategy the truncationStrategy value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setTruncationStrategy(TruncationObject truncationStrategy) { + this.truncationStrategy = truncationStrategy; + return this; + } + + /** + * Get the toolChoice property: Controls whether or not and which tool is called by the model. + * + * @return the toolChoice value. + */ + @Generated + public BinaryData getToolChoice() { + return this.toolChoice; + } + + /** + * Set the toolChoice property: Controls whether or not and which tool is called by the model. + * + * @param toolChoice the toolChoice value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setToolChoice(BinaryData toolChoice) { + this.toolChoice = toolChoice; + return this; + } + + /** + * Get the responseFormat property: Specifies the format that the model must output. + * + * @return the responseFormat value. + */ + @Generated + public BinaryData getResponseFormat() { + return this.responseFormat; + } + + /** + * Set the responseFormat property: Specifies the format that the model must output. + * + * @param responseFormat the responseFormat value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setResponseFormat(BinaryData responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * Get the parallelToolCalls property: If `true` functions will run in parallel during tool use. + * + * @return the parallelToolCalls value. + */ + @Generated + public Boolean isParallelToolCalls() { + return this.parallelToolCalls; + } + + /** + * Set the parallelToolCalls property: If `true` functions will run in parallel during tool use. + * + * @param parallelToolCalls the parallelToolCalls value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setParallelToolCalls(Boolean parallelToolCalls) { + this.parallelToolCalls = parallelToolCalls; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the CreateThreadAndRunOptions object itself. + */ + @Generated + public CreateThreadAndRunOptions setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/DoneEvent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/DoneEvent.java new file mode 100644 index 000000000000..92c0d267fb42 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/DoneEvent.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Terminal event indicating the successful end of a stream. + */ +public final class DoneEvent extends ExpandableStringEnum { + + /** + * Event sent when the stream is done. + */ + @Generated + public static final DoneEvent DONE = fromString("done"); + + /** + * Creates a new instance of DoneEvent value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public DoneEvent() { + } + + /** + * Creates or finds a DoneEvent from its string representation. + * + * @param name a name to look for. + * @return the corresponding DoneEvent. + */ + @Generated + public static DoneEvent fromString(String name) { + return fromString(name, DoneEvent.class); + } + + /** + * Gets known DoneEvent values. + * + * @return known DoneEvent values. + */ + @Generated + public static Collection values() { + return values(DoneEvent.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ErrorEvent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ErrorEvent.java new file mode 100644 index 000000000000..adb93104384b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ErrorEvent.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Terminal event indicating a server side error while streaming. + */ +public final class ErrorEvent extends ExpandableStringEnum { + + /** + * Event sent when an error occurs, such as an internal server error or a timeout. + */ + @Generated + public static final ErrorEvent ERROR = fromString("error"); + + /** + * Creates a new instance of ErrorEvent value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ErrorEvent() { + } + + /** + * Creates or finds a ErrorEvent from its string representation. + * + * @param name a name to look for. + * @return the corresponding ErrorEvent. + */ + @Generated + public static ErrorEvent fromString(String name) { + return fromString(name, ErrorEvent.class); + } + + /** + * Gets known ErrorEvent values. + * + * @return known ErrorEvent values. + */ + @Generated + public static Collection values() { + return values(ErrorEvent.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileDeletionStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileDeletionStatus.java new file mode 100644 index 000000000000..367a036cb59d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileDeletionStatus.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A status response from a file deletion operation. + */ +@Immutable +public final class FileDeletionStatus implements JsonSerializable { + + /* + * The ID of the resource specified for deletion. + */ + @Generated + private final String id; + + /* + * A value indicating whether deletion was successful. + */ + @Generated + private final boolean deleted; + + /* + * The object type, which is always 'file'. + */ + @Generated + private final String object = "file"; + + /** + * Creates an instance of FileDeletionStatus class. + * + * @param id the id value to set. + * @param deleted the deleted value to set. + */ + @Generated + private FileDeletionStatus(String id, boolean deleted) { + this.id = id; + this.deleted = deleted; + } + + /** + * Get the id property: The ID of the resource specified for deletion. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the deleted property: A value indicating whether deletion was successful. + * + * @return the deleted value. + */ + @Generated + public boolean isDeleted() { + return this.deleted; + } + + /** + * Get the object property: The object type, which is always 'file'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeBooleanField("deleted", this.deleted); + jsonWriter.writeStringField("object", this.object); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FileDeletionStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FileDeletionStatus if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FileDeletionStatus. + */ + @Generated + public static FileDeletionStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + boolean deleted = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("deleted".equals(fieldName)) { + deleted = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new FileDeletionStatus(id, deleted); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileInfo.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileInfo.java new file mode 100644 index 000000000000..e011e463c225 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileInfo.java @@ -0,0 +1,239 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +/** + * Represents an agent that can call the model and use tools. + */ +@Immutable +public final class FileInfo implements JsonSerializable { + + /* + * The object type, which is always 'file'. + */ + @Generated + private final String object = "file"; + + /* + * The identifier, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The size of the file, in bytes. + */ + @Generated + private final int bytes; + + /* + * The name of the file. + */ + @Generated + private final String filename; + + /* + * The Unix timestamp, in seconds, representing when this object was created. + */ + @Generated + private final long createdAt; + + /* + * The intended purpose of a file. + */ + @Generated + private final FilePurpose purpose; + + /* + * The state of the file. This field is available in Azure OpenAI only. + */ + @Generated + private FileState status; + + /* + * The error message with details in case processing of this file failed. This field is available in Azure OpenAI + * only. + */ + @Generated + private String statusDetails; + + /** + * Creates an instance of FileInfo class. + * + * @param id the id value to set. + * @param bytes the bytes value to set. + * @param filename the filename value to set. + * @param createdAt the createdAt value to set. + * @param purpose the purpose value to set. + */ + @Generated + private FileInfo(String id, int bytes, String filename, OffsetDateTime createdAt, FilePurpose purpose) { + this.id = id; + this.bytes = bytes; + this.filename = filename; + if (createdAt == null) { + this.createdAt = 0L; + } else { + this.createdAt = createdAt.toEpochSecond(); + } + this.purpose = purpose; + } + + /** + * Get the object property: The object type, which is always 'file'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the id property: The identifier, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the bytes property: The size of the file, in bytes. + * + * @return the bytes value. + */ + @Generated + public int getBytes() { + return this.bytes; + } + + /** + * Get the filename property: The name of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Get the createdAt property: The Unix timestamp, in seconds, representing when this object was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC); + } + + /** + * Get the purpose property: The intended purpose of a file. + * + * @return the purpose value. + */ + @Generated + public FilePurpose getPurpose() { + return this.purpose; + } + + /** + * Get the status property: The state of the file. This field is available in Azure OpenAI only. + * + * @return the status value. + */ + @Generated + public FileState getStatus() { + return this.status; + } + + /** + * Get the statusDetails property: The error message with details in case processing of this file failed. This field + * is available in Azure OpenAI only. + * + * @return the statusDetails value. + */ + @Generated + public String getStatusDetails() { + return this.statusDetails; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeIntField("bytes", this.bytes); + jsonWriter.writeStringField("filename", this.filename); + jsonWriter.writeLongField("created_at", this.createdAt); + jsonWriter.writeStringField("purpose", this.purpose == null ? null : this.purpose.toString()); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeStringField("status_details", this.statusDetails); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FileInfo from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FileInfo if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FileInfo. + */ + @Generated + public static FileInfo fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + int bytes = 0; + String filename = null; + OffsetDateTime createdAt = null; + FilePurpose purpose = null; + FileState status = null; + String statusDetails = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("bytes".equals(fieldName)) { + bytes = reader.getInt(); + } else if ("filename".equals(fieldName)) { + filename = reader.getString(); + } else if ("created_at".equals(fieldName)) { + createdAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader.getLong()), ZoneOffset.UTC); + } else if ("purpose".equals(fieldName)) { + purpose = FilePurpose.fromString(reader.getString()); + } else if ("status".equals(fieldName)) { + status = FileState.fromString(reader.getString()); + } else if ("status_details".equals(fieldName)) { + statusDetails = reader.getString(); + } else { + reader.skipChildren(); + } + } + FileInfo deserializedFileInfo = new FileInfo(id, bytes, filename, createdAt, purpose); + deserializedFileInfo.status = status; + deserializedFileInfo.statusDetails = statusDetails; + return deserializedFileInfo; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileListResponse.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileListResponse.java new file mode 100644 index 000000000000..8f09f507bce6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileListResponse.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The response data from a file list operation. + */ +@Immutable +public final class FileListResponse implements JsonSerializable { + + /* + * The object type, which is always 'list'. + */ + @Generated + private final String object = "list"; + + /* + * The files returned for the request. + */ + @Generated + private final List data; + + /** + * Creates an instance of FileListResponse class. + * + * @param data the data value to set. + */ + @Generated + private FileListResponse(List data) { + this.data = data; + } + + /** + * Get the object property: The object type, which is always 'list'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the data property: The files returned for the request. + * + * @return the data value. + */ + @Generated + public List getData() { + return this.data; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeArrayField("data", this.data, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FileListResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FileListResponse if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FileListResponse. + */ + @Generated + public static FileListResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List data = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("data".equals(fieldName)) { + data = reader.readArray(reader1 -> FileInfo.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new FileListResponse(data); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FilePurpose.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FilePurpose.java new file mode 100644 index 000000000000..3c73b2b2f71b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FilePurpose.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The possible values denoting the intended usage of a file. + */ +public final class FilePurpose extends ExpandableStringEnum { + + /** + * Indicates a file is used for fine tuning input. + */ + @Generated + public static final FilePurpose FINE_TUNE = fromString("fine-tune"); + + /** + * Indicates a file is used for fine tuning results. + */ + @Generated + public static final FilePurpose FINE_TUNE_RESULTS = fromString("fine-tune-results"); + + /** + * Indicates a file is used as input to agents. + */ + @Generated + public static final FilePurpose AGENTS = fromString("assistants"); + + /** + * Indicates a file is used as output by agents. + */ + @Generated + public static final FilePurpose AGENTS_OUTPUT = fromString("assistants_output"); + + /** + * Indicates a file is used as input to . + */ + @Generated + public static final FilePurpose BATCH = fromString("batch"); + + /** + * Indicates a file is used as output by a vector store batch operation. + */ + @Generated + public static final FilePurpose BATCH_OUTPUT = fromString("batch_output"); + + /** + * Indicates a file is used as input to a vision operation. + */ + @Generated + public static final FilePurpose VISION = fromString("vision"); + + /** + * Creates a new instance of FilePurpose value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public FilePurpose() { + } + + /** + * Creates or finds a FilePurpose from its string representation. + * + * @param name a name to look for. + * @return the corresponding FilePurpose. + */ + @Generated + public static FilePurpose fromString(String name) { + return fromString(name, FilePurpose.class); + } + + /** + * Gets known FilePurpose values. + * + * @return known FilePurpose values. + */ + @Generated + public static Collection values() { + return values(FilePurpose.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchRankingOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchRankingOptions.java new file mode 100644 index 000000000000..3c936e77b5bb --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchRankingOptions.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Ranking options for file search. + */ +@Immutable +public final class FileSearchRankingOptions implements JsonSerializable { + + /* + * File search ranker. + */ + @Generated + private final String ranker; + + /* + * Ranker search threshold. + */ + @Generated + private final double scoreThreshold; + + /** + * Creates an instance of FileSearchRankingOptions class. + * + * @param ranker the ranker value to set. + * @param scoreThreshold the scoreThreshold value to set. + */ + @Generated + public FileSearchRankingOptions(String ranker, double scoreThreshold) { + this.ranker = ranker; + this.scoreThreshold = scoreThreshold; + } + + /** + * Get the ranker property: File search ranker. + * + * @return the ranker value. + */ + @Generated + public String getRanker() { + return this.ranker; + } + + /** + * Get the scoreThreshold property: Ranker search threshold. + * + * @return the scoreThreshold value. + */ + @Generated + public double getScoreThreshold() { + return this.scoreThreshold; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("ranker", this.ranker); + jsonWriter.writeDoubleField("score_threshold", this.scoreThreshold); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FileSearchRankingOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FileSearchRankingOptions if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FileSearchRankingOptions. + */ + @Generated + public static FileSearchRankingOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String ranker = null; + double scoreThreshold = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("ranker".equals(fieldName)) { + ranker = reader.getString(); + } else if ("score_threshold".equals(fieldName)) { + scoreThreshold = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new FileSearchRankingOptions(ranker, scoreThreshold); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolCallContent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolCallContent.java new file mode 100644 index 000000000000..5ede85c7aa51 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolCallContent.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The file search result content object. + */ +@Immutable +public final class FileSearchToolCallContent implements JsonSerializable { + + /* + * The type of the content. + */ + @Generated + private final String type = "text"; + + /* + * The text content of the file. + */ + @Generated + private final String text; + + /** + * Creates an instance of FileSearchToolCallContent class. + * + * @param text the text value to set. + */ + @Generated + private FileSearchToolCallContent(String text) { + this.text = text; + } + + /** + * Get the type property: The type of the content. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the text property: The text content of the file. + * + * @return the text value. + */ + @Generated + public String getText() { + return this.text; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeStringField("text", this.text); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FileSearchToolCallContent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FileSearchToolCallContent if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FileSearchToolCallContent. + */ + @Generated + public static FileSearchToolCallContent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String text = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("text".equals(fieldName)) { + text = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new FileSearchToolCallContent(text); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolDefinition.java new file mode 100644 index 000000000000..bf2eea7ad4e2 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolDefinition.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for a file search tool as used to configure an agent. + */ +@Fluent +public final class FileSearchToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "file_search"; + + /* + * Options overrides for the file search tool. + */ + @Generated + private FileSearchToolDefinitionDetails fileSearch; + + /** + * Creates an instance of FileSearchToolDefinition class. + */ + @Generated + public FileSearchToolDefinition() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the fileSearch property: Options overrides for the file search tool. + * + * @return the fileSearch value. + */ + @Generated + public FileSearchToolDefinitionDetails getFileSearch() { + return this.fileSearch; + } + + /** + * Set the fileSearch property: Options overrides for the file search tool. + * + * @param fileSearch the fileSearch value to set. + * @return the FileSearchToolDefinition object itself. + */ + @Generated + public FileSearchToolDefinition setFileSearch(FileSearchToolDefinitionDetails fileSearch) { + this.fileSearch = fileSearch; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("file_search", this.fileSearch); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FileSearchToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FileSearchToolDefinition if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the FileSearchToolDefinition. + */ + @Generated + public static FileSearchToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FileSearchToolDefinition deserializedFileSearchToolDefinition = new FileSearchToolDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedFileSearchToolDefinition.type = reader.getString(); + } else if ("file_search".equals(fieldName)) { + deserializedFileSearchToolDefinition.fileSearch = FileSearchToolDefinitionDetails.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedFileSearchToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolDefinitionDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolDefinitionDetails.java new file mode 100644 index 000000000000..4c64c6daaf9c --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolDefinitionDetails.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Options overrides for the file search tool. + */ +@Fluent +public final class FileSearchToolDefinitionDetails implements JsonSerializable { + + /* + * The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for + * gpt-3.5-turbo. This number should be between 1 and 50 inclusive. + * + * Note that the file search tool may output fewer than `max_num_results` results. See the file search tool + * documentation for more information. + */ + @Generated + private Integer maxNumResults; + + /* + * Ranking options for file search. + */ + @Generated + private FileSearchRankingOptions rankingOptions; + + /** + * Creates an instance of FileSearchToolDefinitionDetails class. + */ + @Generated + public FileSearchToolDefinitionDetails() { + } + + /** + * Get the maxNumResults property: The maximum number of results the file search tool should output. The default is + * 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. + * + * Note that the file search tool may output fewer than `max_num_results` results. See the file search tool + * documentation for more information. + * + * @return the maxNumResults value. + */ + @Generated + public Integer getMaxNumResults() { + return this.maxNumResults; + } + + /** + * Set the maxNumResults property: The maximum number of results the file search tool should output. The default is + * 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. + * + * Note that the file search tool may output fewer than `max_num_results` results. See the file search tool + * documentation for more information. + * + * @param maxNumResults the maxNumResults value to set. + * @return the FileSearchToolDefinitionDetails object itself. + */ + @Generated + public FileSearchToolDefinitionDetails setMaxNumResults(Integer maxNumResults) { + this.maxNumResults = maxNumResults; + return this; + } + + /** + * Get the rankingOptions property: Ranking options for file search. + * + * @return the rankingOptions value. + */ + @Generated + public FileSearchRankingOptions getRankingOptions() { + return this.rankingOptions; + } + + /** + * Set the rankingOptions property: Ranking options for file search. + * + * @param rankingOptions the rankingOptions value to set. + * @return the FileSearchToolDefinitionDetails object itself. + */ + @Generated + public FileSearchToolDefinitionDetails setRankingOptions(FileSearchRankingOptions rankingOptions) { + this.rankingOptions = rankingOptions; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("max_num_results", this.maxNumResults); + jsonWriter.writeJsonField("ranking_options", this.rankingOptions); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FileSearchToolDefinitionDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FileSearchToolDefinitionDetails if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the FileSearchToolDefinitionDetails. + */ + @Generated + public static FileSearchToolDefinitionDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FileSearchToolDefinitionDetails deserializedFileSearchToolDefinitionDetails + = new FileSearchToolDefinitionDetails(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("max_num_results".equals(fieldName)) { + deserializedFileSearchToolDefinitionDetails.maxNumResults = reader.getNullable(JsonReader::getInt); + } else if ("ranking_options".equals(fieldName)) { + deserializedFileSearchToolDefinitionDetails.rankingOptions + = FileSearchRankingOptions.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedFileSearchToolDefinitionDetails; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolResource.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolResource.java new file mode 100644 index 000000000000..22d5a2432a15 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileSearchToolResource.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * A set of resources that are used by the `file_search` tool. + */ +@Fluent +public final class FileSearchToolResource implements JsonSerializable { + + /* + * The ID of the vector store attached to this agent. There can be a maximum of 1 vector + * store attached to the agent. + */ + @Generated + private List vectorStoreIds; + + /* + * The list of vector store configuration objects from Azure. + * This list is limited to one element. + * The only element of this list contains the list of azure asset IDs used by the search tool. + */ + @Generated + private List vectorStores; + + /** + * Creates an instance of FileSearchToolResource class. + */ + @Generated + public FileSearchToolResource() { + } + + /** + * Get the vectorStoreIds property: The ID of the vector store attached to this agent. There can be a maximum of 1 + * vector + * store attached to the agent. + * + * @return the vectorStoreIds value. + */ + @Generated + public List getVectorStoreIds() { + return this.vectorStoreIds; + } + + /** + * Set the vectorStoreIds property: The ID of the vector store attached to this agent. There can be a maximum of 1 + * vector + * store attached to the agent. + * + * @param vectorStoreIds the vectorStoreIds value to set. + * @return the FileSearchToolResource object itself. + */ + @Generated + public FileSearchToolResource setVectorStoreIds(List vectorStoreIds) { + this.vectorStoreIds = vectorStoreIds; + return this; + } + + /** + * Get the vectorStores property: The list of vector store configuration objects from Azure. + * This list is limited to one element. + * The only element of this list contains the list of azure asset IDs used by the search tool. + * + * @return the vectorStores value. + */ + @Generated + public List getVectorStores() { + return this.vectorStores; + } + + /** + * Set the vectorStores property: The list of vector store configuration objects from Azure. + * This list is limited to one element. + * The only element of this list contains the list of azure asset IDs used by the search tool. + * + * @param vectorStores the vectorStores value to set. + * @return the FileSearchToolResource object itself. + */ + @Generated + public FileSearchToolResource setVectorStores(List vectorStores) { + this.vectorStores = vectorStores; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("vector_store_ids", this.vectorStoreIds, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("vector_stores", this.vectorStores, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FileSearchToolResource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FileSearchToolResource if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the FileSearchToolResource. + */ + @Generated + public static FileSearchToolResource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FileSearchToolResource deserializedFileSearchToolResource = new FileSearchToolResource(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("vector_store_ids".equals(fieldName)) { + List vectorStoreIds = reader.readArray(reader1 -> reader1.getString()); + deserializedFileSearchToolResource.vectorStoreIds = vectorStoreIds; + } else if ("vector_stores".equals(fieldName)) { + List vectorStores + = reader.readArray(reader1 -> VectorStoreConfigurations.fromJson(reader1)); + deserializedFileSearchToolResource.vectorStores = vectorStores; + } else { + reader.skipChildren(); + } + } + return deserializedFileSearchToolResource; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileState.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileState.java new file mode 100644 index 000000000000..9a67a6f937e2 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FileState.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The state of the file. + */ +public final class FileState extends ExpandableStringEnum { + + /** + * The file has been uploaded but it's not yet processed. This state is not returned by Azure OpenAI and exposed + * only for + * compatibility. It can be categorized as an inactive state. + */ + @Generated + public static final FileState UPLOADED = fromString("uploaded"); + + /** + * The operation was created and is not queued to be processed in the future. It can be categorized as an inactive + * state. + */ + @Generated + public static final FileState PENDING = fromString("pending"); + + /** + * The operation has started to be processed. It can be categorized as an active state. + */ + @Generated + public static final FileState RUNNING = fromString("running"); + + /** + * The operation has successfully processed and is ready for consumption. It can be categorized as a terminal state. + */ + @Generated + public static final FileState PROCESSED = fromString("processed"); + + /** + * The operation has completed processing with a failure and cannot be further consumed. It can be categorized as a + * terminal state. + */ + @Generated + public static final FileState ERROR = fromString("error"); + + /** + * The entity is in the process to be deleted. This state is not returned by Azure OpenAI and exposed only for + * compatibility. + * It can be categorized as an active state. + */ + @Generated + public static final FileState DELETING = fromString("deleting"); + + /** + * The entity has been deleted but may still be referenced by other entities predating the deletion. It can be + * categorized as a + * terminal state. + */ + @Generated + public static final FileState DELETED = fromString("deleted"); + + /** + * Creates a new instance of FileState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public FileState() { + } + + /** + * Creates or finds a FileState from its string representation. + * + * @param name a name to look for. + * @return the corresponding FileState. + */ + @Generated + public static FileState fromString(String name) { + return fromString(name, FileState.class); + } + + /** + * Gets known FileState values. + * + * @return known FileState values. + */ + @Generated + public static Collection values() { + return values(FileState.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionDefinition.java new file mode 100644 index 000000000000..51279e906fb6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionDefinition.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for a function. + */ +@Fluent +public final class FunctionDefinition implements JsonSerializable { + + /* + * The name of the function to be called. + */ + @Generated + private final String name; + + /* + * A description of what the function does, used by the model to choose when and how to call the function. + */ + @Generated + private String description; + + /* + * The parameters the functions accepts, described as a JSON Schema object. + */ + @Generated + private final BinaryData parameters; + + /** + * Creates an instance of FunctionDefinition class. + * + * @param name the name value to set. + * @param parameters the parameters value to set. + */ + @Generated + public FunctionDefinition(String name, BinaryData parameters) { + this.name = name; + this.parameters = parameters; + } + + /** + * Get the name property: The name of the function to be called. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the description property: A description of what the function does, used by the model to choose when and how + * to call the function. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: A description of what the function does, used by the model to choose when and how + * to call the function. + * + * @param description the description value to set. + * @return the FunctionDefinition object itself. + */ + @Generated + public FunctionDefinition setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the parameters property: The parameters the functions accepts, described as a JSON Schema object. + * + * @return the parameters value. + */ + @Generated + public BinaryData getParameters() { + return this.parameters; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeFieldName("parameters"); + this.parameters.writeTo(jsonWriter); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FunctionDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FunctionDefinition if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FunctionDefinition. + */ + @Generated + public static FunctionDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + BinaryData parameters = null; + String description = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("parameters".equals(fieldName)) { + parameters + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else { + reader.skipChildren(); + } + } + FunctionDefinition deserializedFunctionDefinition = new FunctionDefinition(name, parameters); + deserializedFunctionDefinition.description = description; + return deserializedFunctionDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionName.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionName.java new file mode 100644 index 000000000000..f982c474cca3 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionName.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The function name that will be used, if using the `function` tool. + */ +@Immutable +public final class FunctionName implements JsonSerializable { + + /* + * The name of the function to call + */ + @Generated + private final String name; + + /** + * Creates an instance of FunctionName class. + * + * @param name the name value to set. + */ + @Generated + public FunctionName(String name) { + this.name = name; + } + + /** + * Get the name property: The name of the function to call. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FunctionName from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FunctionName if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FunctionName. + */ + @Generated + public static FunctionName fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new FunctionName(name); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionToolDefinition.java new file mode 100644 index 000000000000..0a1c3e934883 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/FunctionToolDefinition.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for a function tool as used to configure an agent. + */ +@Immutable +public final class FunctionToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "function"; + + /* + * The definition of the concrete function that the function tool should call. + */ + @Generated + private final FunctionDefinition function; + + /** + * Creates an instance of FunctionToolDefinition class. + * + * @param function the function value to set. + */ + @Generated + public FunctionToolDefinition(FunctionDefinition function) { + this.function = function; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the function property: The definition of the concrete function that the function tool should call. + * + * @return the function value. + */ + @Generated + public FunctionDefinition getFunction() { + return this.function; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("function", this.function); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FunctionToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FunctionToolDefinition if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FunctionToolDefinition. + */ + @Generated + public static FunctionToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FunctionDefinition function = null; + String type = "function"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("function".equals(fieldName)) { + function = FunctionDefinition.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + FunctionToolDefinition deserializedFunctionToolDefinition = new FunctionToolDefinition(function); + deserializedFunctionToolDefinition.type = type; + return deserializedFunctionToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ImageDetailLevel.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ImageDetailLevel.java new file mode 100644 index 000000000000..4f922b4c589e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ImageDetailLevel.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies an image's detail level. Can be 'auto', 'low', 'high', or an unknown future value. + */ +public final class ImageDetailLevel extends ExpandableStringEnum { + + /** + * Automatically select an appropriate detail level. + */ + @Generated + public static final ImageDetailLevel AUTO = fromString("auto"); + + /** + * Use a lower detail level to reduce bandwidth or cost. + */ + @Generated + public static final ImageDetailLevel LOW = fromString("low"); + + /** + * Use a higher detail level—potentially more resource-intensive. + */ + @Generated + public static final ImageDetailLevel HIGH = fromString("high"); + + /** + * Creates a new instance of ImageDetailLevel value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ImageDetailLevel() { + } + + /** + * Creates or finds a ImageDetailLevel from its string representation. + * + * @param name a name to look for. + * @return the corresponding ImageDetailLevel. + */ + @Generated + public static ImageDetailLevel fromString(String name) { + return fromString(name, ImageDetailLevel.class); + } + + /** + * Gets known ImageDetailLevel values. + * + * @return known ImageDetailLevel values. + */ + @Generated + public static Collection values() { + return values(ImageDetailLevel.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/IncompleteDetailsReason.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/IncompleteDetailsReason.java new file mode 100644 index 000000000000..19eadf00322b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/IncompleteDetailsReason.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The reason why the run is incomplete. This will point to which specific token limit was reached over the course of + * the run. + */ +public final class IncompleteDetailsReason extends ExpandableStringEnum { + + /** + * Maximum completion tokens exceeded. + */ + @Generated + public static final IncompleteDetailsReason MAX_COMPLETION_TOKENS = fromString("max_completion_tokens"); + + /** + * Maximum prompt tokens exceeded. + */ + @Generated + public static final IncompleteDetailsReason MAX_PROMPT_TOKENS = fromString("max_prompt_tokens"); + + /** + * Creates a new instance of IncompleteDetailsReason value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public IncompleteDetailsReason() { + } + + /** + * Creates or finds a IncompleteDetailsReason from its string representation. + * + * @param name a name to look for. + * @return the corresponding IncompleteDetailsReason. + */ + @Generated + public static IncompleteDetailsReason fromString(String name) { + return fromString(name, IncompleteDetailsReason.class); + } + + /** + * Gets known IncompleteDetailsReason values. + * + * @return known IncompleteDetailsReason values. + */ + @Generated + public static Collection values() { + return values(IncompleteDetailsReason.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/IncompleteRunDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/IncompleteRunDetails.java new file mode 100644 index 000000000000..3082f1eec0e1 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/IncompleteRunDetails.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Details on why the run is incomplete. Will be `null` if the run is not incomplete. + */ +@Immutable +public final class IncompleteRunDetails implements JsonSerializable { + + /* + * The reason why the run is incomplete. This indicates which specific token limit was reached during the run. + */ + @Generated + private final IncompleteDetailsReason reason; + + /** + * Creates an instance of IncompleteRunDetails class. + * + * @param reason the reason value to set. + */ + @Generated + private IncompleteRunDetails(IncompleteDetailsReason reason) { + this.reason = reason; + } + + /** + * Get the reason property: The reason why the run is incomplete. This indicates which specific token limit was + * reached during the run. + * + * @return the reason value. + */ + @Generated + public IncompleteDetailsReason getReason() { + return this.reason; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("reason", this.reason == null ? null : this.reason.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IncompleteRunDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IncompleteRunDetails if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the IncompleteRunDetails. + */ + @Generated + public static IncompleteRunDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + IncompleteDetailsReason reason = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("reason".equals(fieldName)) { + reason = IncompleteDetailsReason.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new IncompleteRunDetails(reason); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ListSortOrder.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ListSortOrder.java new file mode 100644 index 000000000000..e73d7aaae527 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ListSortOrder.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The available sorting options when requesting a list of response objects. + */ +public final class ListSortOrder extends ExpandableStringEnum { + + /** + * Specifies an ascending sort order. + */ + @Generated + public static final ListSortOrder ASCENDING = fromString("asc"); + + /** + * Specifies a descending sort order. + */ + @Generated + public static final ListSortOrder DESCENDING = fromString("desc"); + + /** + * Creates a new instance of ListSortOrder value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ListSortOrder() { + } + + /** + * Creates or finds a ListSortOrder from its string representation. + * + * @param name a name to look for. + * @return the corresponding ListSortOrder. + */ + @Generated + public static ListSortOrder fromString(String name) { + return fromString(name, ListSortOrder.class); + } + + /** + * Gets known ListSortOrder values. + * + * @return known ListSortOrder values. + */ + @Generated + public static Collection values() { + return values(ListSortOrder.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageAttachment.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageAttachment.java new file mode 100644 index 000000000000..15581b45ee8a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageAttachment.java @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * This describes to which tools a file has been attached. + */ +@Fluent +public final class MessageAttachment implements JsonSerializable { + + /* + * The ID of the file to attach to the message. + */ + @Generated + private String fileId; + + /* + * Azure asset ID. + */ + @Generated + private VectorStoreDataSource dataSource; + + /* + * The tools to add to this file. + */ + @Generated + private final List tools; + + /** + * Creates an instance of MessageAttachment class. + * + * @param tools the tools value to set. + */ + @Generated + public MessageAttachment(List tools) { + this.tools = tools; + } + + /** + * Get the fileId property: The ID of the file to attach to the message. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * Set the fileId property: The ID of the file to attach to the message. + * + * @param fileId the fileId value to set. + * @return the MessageAttachment object itself. + */ + @Generated + public MessageAttachment setFileId(String fileId) { + this.fileId = fileId; + return this; + } + + /** + * Get the dataSource property: Azure asset ID. + * + * @return the dataSource value. + */ + @Generated + public VectorStoreDataSource getDataSource() { + return this.dataSource; + } + + /** + * Set the dataSource property: Azure asset ID. + * + * @param dataSource the dataSource value to set. + * @return the MessageAttachment object itself. + */ + @Generated + public MessageAttachment setDataSource(VectorStoreDataSource dataSource) { + this.dataSource = dataSource; + return this; + } + + /** + * Get the tools property: The tools to add to this file. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("tools", this.tools, + (writer, element) -> writer.writeUntyped(element == null ? null : element.toObject(Object.class))); + jsonWriter.writeStringField("file_id", this.fileId); + jsonWriter.writeJsonField("data_source", this.dataSource); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageAttachment from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageAttachment if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageAttachment. + */ + @Generated + public static MessageAttachment fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List tools = null; + String fileId = null; + VectorStoreDataSource dataSource = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("tools".equals(fieldName)) { + tools = reader.readArray(reader1 -> reader1 + .getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } else if ("file_id".equals(fieldName)) { + fileId = reader.getString(); + } else if ("data_source".equals(fieldName)) { + dataSource = VectorStoreDataSource.fromJson(reader); + } else { + reader.skipChildren(); + } + } + MessageAttachment deserializedMessageAttachment = new MessageAttachment(tools); + deserializedMessageAttachment.fileId = fileId; + deserializedMessageAttachment.dataSource = dataSource; + return deserializedMessageAttachment; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageBlockType.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageBlockType.java new file mode 100644 index 000000000000..7dd8a485ff23 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageBlockType.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies the kind of content block within a message. Could be text, an image file, an external image URL, or an + * unknown future type. + */ +public final class MessageBlockType extends ExpandableStringEnum { + + /** + * Indicates a block containing text content. + */ + @Generated + public static final MessageBlockType TEXT = fromString("text"); + + /** + * Indicates a block referencing an internally uploaded image file. + */ + @Generated + public static final MessageBlockType IMAGE_FILE = fromString("image_file"); + + /** + * Indicates a block referencing an external image URL. + */ + @Generated + public static final MessageBlockType IMAGE_URL = fromString("image_url"); + + /** + * Creates a new instance of MessageBlockType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public MessageBlockType() { + } + + /** + * Creates or finds a MessageBlockType from its string representation. + * + * @param name a name to look for. + * @return the corresponding MessageBlockType. + */ + @Generated + public static MessageBlockType fromString(String name) { + return fromString(name, MessageBlockType.class); + } + + /** + * Gets known MessageBlockType values. + * + * @return known MessageBlockType values. + */ + @Generated + public static Collection values() { + return values(MessageBlockType.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageContent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageContent.java new file mode 100644 index 000000000000..3e581421c4d4 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageContent.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An abstract representation of a single item of thread message content. + */ +@Immutable +public class MessageContent implements JsonSerializable { + + /* + * The object type. + */ + @Generated + private String type = "MessageContent"; + + /** + * Creates an instance of MessageContent class. + */ + @Generated + protected MessageContent() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageContent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageContent if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the MessageContent. + */ + @Generated + public static MessageContent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("text".equals(discriminatorValue)) { + return MessageTextContent.fromJson(readerToUse.reset()); + } else if ("image_file".equals(discriminatorValue)) { + return MessageImageFileContent.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static MessageContent fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageContent deserializedMessageContent = new MessageContent(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedMessageContent.type = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedMessageContent; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDelta.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDelta.java new file mode 100644 index 000000000000..e69154e82d6e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDelta.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Represents the typed 'delta' payload within a streaming message delta chunk. + */ +@Immutable +public final class MessageDelta implements JsonSerializable { + + /* + * The entity that produced the message. + */ + @Generated + private final MessageRole role; + + /* + * The content of the message as an array of text and/or images. + */ + @Generated + private final List content; + + /** + * Creates an instance of MessageDelta class. + * + * @param role the role value to set. + * @param content the content value to set. + */ + @Generated + private MessageDelta(MessageRole role, List content) { + this.role = role; + this.content = content; + } + + /** + * Get the role property: The entity that produced the message. + * + * @return the role value. + */ + @Generated + public MessageRole getRole() { + return this.role; + } + + /** + * Get the content property: The content of the message as an array of text and/or images. + * + * @return the content value. + */ + @Generated + public List getContent() { + return this.content; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("role", this.role == null ? null : this.role.toString()); + jsonWriter.writeArrayField("content", this.content, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDelta from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDelta if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageDelta. + */ + @Generated + public static MessageDelta fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageRole role = null; + List content = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("role".equals(fieldName)) { + role = MessageRole.fromString(reader.getString()); + } else if ("content".equals(fieldName)) { + content = reader.readArray(reader1 -> MessageDeltaContent.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new MessageDelta(role, content); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaChunk.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaChunk.java new file mode 100644 index 000000000000..68576db0e5dc --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaChunk.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a message delta i.e. any changed fields on a message during streaming. + */ +@Immutable +public final class MessageDeltaChunk implements JsonSerializable { + + /* + * The identifier of the message, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The object type, which is always `thread.message.delta`. + */ + @Generated + private final String object = "thread.message.delta"; + + /* + * The delta containing the fields that have changed on the Message. + */ + @Generated + private final MessageDelta delta; + + /** + * Creates an instance of MessageDeltaChunk class. + * + * @param id the id value to set. + * @param delta the delta value to set. + */ + @Generated + private MessageDeltaChunk(String id, MessageDelta delta) { + this.id = id; + this.delta = delta; + } + + /** + * Get the id property: The identifier of the message, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the object property: The object type, which is always `thread.message.delta`. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the delta property: The delta containing the fields that have changed on the Message. + * + * @return the delta value. + */ + @Generated + public MessageDelta getDelta() { + return this.delta; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeJsonField("delta", this.delta); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaChunk from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaChunk if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageDeltaChunk. + */ + @Generated + public static MessageDeltaChunk fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + MessageDelta delta = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("delta".equals(fieldName)) { + delta = MessageDelta.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new MessageDeltaChunk(id, delta); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaContent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaContent.java new file mode 100644 index 000000000000..cf1ff2b5c97f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaContent.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The abstract base representation of a partial streamed message content payload. + */ +@Immutable +public class MessageDeltaContent implements JsonSerializable { + + /* + * The type of content for this content part. + */ + @Generated + private String type = "MessageDeltaContent"; + + /* + * The index of the content part of the message. + */ + @Generated + private final int index; + + /** + * Creates an instance of MessageDeltaContent class. + * + * @param index the index value to set. + */ + @Generated + protected MessageDeltaContent(int index) { + this.index = index; + } + + /** + * Get the type property: The type of content for this content part. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the index property: The index of the content part of the message. + * + * @return the index value. + */ + @Generated + public int getIndex() { + return this.index; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaContent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaContent if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageDeltaContent. + */ + @Generated + public static MessageDeltaContent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("image_file".equals(discriminatorValue)) { + return MessageDeltaImageFileContent.fromJson(readerToUse.reset()); + } else if ("text".equals(discriminatorValue)) { + return MessageDeltaTextContent.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static MessageDeltaContent fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + MessageDeltaContent deserializedMessageDeltaContent = new MessageDeltaContent(index); + deserializedMessageDeltaContent.type = type; + return deserializedMessageDeltaContent; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaImageFileContent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaImageFileContent.java new file mode 100644 index 000000000000..c263917f7314 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaImageFileContent.java @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a streamed image file content part within a streaming message delta chunk. + */ +@Immutable +public final class MessageDeltaImageFileContent extends MessageDeltaContent { + + /* + * The type of content for this content part. + */ + @Generated + private String type = "image_file"; + + /* + * The image_file data. + */ + @Generated + private MessageDeltaImageFileContentObject imageFile; + + /** + * Creates an instance of MessageDeltaImageFileContent class. + * + * @param index the index value to set. + */ + @Generated + private MessageDeltaImageFileContent(int index) { + super(index); + } + + /** + * Get the type property: The type of content for this content part. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the imageFile property: The image_file data. + * + * @return the imageFile value. + */ + @Generated + public MessageDeltaImageFileContentObject getImageFile() { + return this.imageFile; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", getIndex()); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("image_file", this.imageFile); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaImageFileContent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaImageFileContent if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageDeltaImageFileContent. + */ + @Generated + public static MessageDeltaImageFileContent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String type = "image_file"; + MessageDeltaImageFileContentObject imageFile = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("image_file".equals(fieldName)) { + imageFile = MessageDeltaImageFileContentObject.fromJson(reader); + } else { + reader.skipChildren(); + } + } + MessageDeltaImageFileContent deserializedMessageDeltaImageFileContent + = new MessageDeltaImageFileContent(index); + deserializedMessageDeltaImageFileContent.type = type; + deserializedMessageDeltaImageFileContent.imageFile = imageFile; + return deserializedMessageDeltaImageFileContent; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaImageFileContentObject.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaImageFileContentObject.java new file mode 100644 index 000000000000..a481d88e11f5 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaImageFileContentObject.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents the 'image_file' payload within streaming image file content. + */ +@Immutable +public final class MessageDeltaImageFileContentObject implements JsonSerializable { + + /* + * The file ID of the image in the message content. + */ + @Generated + private String fileId; + + /** + * Creates an instance of MessageDeltaImageFileContentObject class. + */ + @Generated + private MessageDeltaImageFileContentObject() { + } + + /** + * Get the fileId property: The file ID of the image in the message content. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaImageFileContentObject from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaImageFileContentObject if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the MessageDeltaImageFileContentObject. + */ + @Generated + public static MessageDeltaImageFileContentObject fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageDeltaImageFileContentObject deserializedMessageDeltaImageFileContentObject + = new MessageDeltaImageFileContentObject(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + deserializedMessageDeltaImageFileContentObject.fileId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedMessageDeltaImageFileContentObject; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextAnnotation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextAnnotation.java new file mode 100644 index 000000000000..3661b19fd6ee --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextAnnotation.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The abstract base representation of a streamed text content part's text annotation. + */ +@Immutable +public class MessageDeltaTextAnnotation implements JsonSerializable { + + /* + * The type of the text content annotation. + */ + @Generated + private String type = "MessageDeltaTextAnnotation"; + + /* + * The index of the annotation within a text content part. + */ + @Generated + private final int index; + + /** + * Creates an instance of MessageDeltaTextAnnotation class. + * + * @param index the index value to set. + */ + @Generated + protected MessageDeltaTextAnnotation(int index) { + this.index = index; + } + + /** + * Get the type property: The type of the text content annotation. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the index property: The index of the annotation within a text content part. + * + * @return the index value. + */ + @Generated + public int getIndex() { + return this.index; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaTextAnnotation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaTextAnnotation if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageDeltaTextAnnotation. + */ + @Generated + public static MessageDeltaTextAnnotation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("url_citation".equals(discriminatorValue)) { + return MessageDeltaTextUrlCitationAnnotation.fromJson(readerToUse.reset()); + } else if ("file_citation".equals(discriminatorValue)) { + return MessageDeltaTextFileCitationAnnotation.fromJson(readerToUse.reset()); + } else if ("file_path".equals(discriminatorValue)) { + return MessageDeltaTextFilePathAnnotation.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static MessageDeltaTextAnnotation fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + MessageDeltaTextAnnotation deserializedMessageDeltaTextAnnotation = new MessageDeltaTextAnnotation(index); + deserializedMessageDeltaTextAnnotation.type = type; + return deserializedMessageDeltaTextAnnotation; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextContent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextContent.java new file mode 100644 index 000000000000..f7359f68a655 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextContent.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a streamed text content part within a streaming message delta chunk. + */ +@Immutable +public final class MessageDeltaTextContent extends MessageDeltaContent { + + /* + * The type of content for this content part. + */ + @Generated + private String type = "text"; + + /* + * The text content details. + */ + @Generated + private MessageDeltaTextContentObject text; + + /** + * Creates an instance of MessageDeltaTextContent class. + * + * @param index the index value to set. + */ + @Generated + private MessageDeltaTextContent(int index) { + super(index); + } + + /** + * Get the type property: The type of content for this content part. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the text property: The text content details. + * + * @return the text value. + */ + @Generated + public MessageDeltaTextContentObject getText() { + return this.text; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", getIndex()); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("text", this.text); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaTextContent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaTextContent if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageDeltaTextContent. + */ + @Generated + public static MessageDeltaTextContent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String type = "text"; + MessageDeltaTextContentObject text = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("text".equals(fieldName)) { + text = MessageDeltaTextContentObject.fromJson(reader); + } else { + reader.skipChildren(); + } + } + MessageDeltaTextContent deserializedMessageDeltaTextContent = new MessageDeltaTextContent(index); + deserializedMessageDeltaTextContent.type = type; + deserializedMessageDeltaTextContent.text = text; + return deserializedMessageDeltaTextContent; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextContentObject.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextContentObject.java new file mode 100644 index 000000000000..272e36bd45be --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextContentObject.java @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Represents the data of a streamed text content part within a streaming message delta chunk. + */ +@Immutable +public final class MessageDeltaTextContentObject implements JsonSerializable { + + /* + * The data that makes up the text. + */ + @Generated + private String value; + + /* + * Annotations for the text. + */ + @Generated + private List annotations; + + /** + * Creates an instance of MessageDeltaTextContentObject class. + */ + @Generated + private MessageDeltaTextContentObject() { + } + + /** + * Get the value property: The data that makes up the text. + * + * @return the value value. + */ + @Generated + public String getValue() { + return this.value; + } + + /** + * Get the annotations property: Annotations for the text. + * + * @return the annotations value. + */ + @Generated + public List getAnnotations() { + return this.annotations; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", this.value); + jsonWriter.writeArrayField("annotations", this.annotations, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaTextContentObject from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaTextContentObject if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the MessageDeltaTextContentObject. + */ + @Generated + public static MessageDeltaTextContentObject fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageDeltaTextContentObject deserializedMessageDeltaTextContentObject + = new MessageDeltaTextContentObject(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("value".equals(fieldName)) { + deserializedMessageDeltaTextContentObject.value = reader.getString(); + } else if ("annotations".equals(fieldName)) { + List annotations + = reader.readArray(reader1 -> MessageDeltaTextAnnotation.fromJson(reader1)); + deserializedMessageDeltaTextContentObject.annotations = annotations; + } else { + reader.skipChildren(); + } + } + return deserializedMessageDeltaTextContentObject; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFileCitationAnnotation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFileCitationAnnotation.java new file mode 100644 index 000000000000..db78b7fefd2c --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFileCitationAnnotation.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a streamed file citation applied to a streaming text content part. + */ +@Immutable +public final class MessageDeltaTextFileCitationAnnotation extends MessageDeltaTextAnnotation { + + /* + * The type of the text content annotation. + */ + @Generated + private String type = "file_citation"; + + /* + * The file citation information. + */ + @Generated + private MessageDeltaTextFileCitationAnnotationObject fileCitation; + + /* + * The text in the message content that needs to be replaced + */ + @Generated + private String text; + + /* + * The start index of this annotation in the content text. + */ + @Generated + private Integer startIndex; + + /* + * The end index of this annotation in the content text. + */ + @Generated + private Integer endIndex; + + /** + * Creates an instance of MessageDeltaTextFileCitationAnnotation class. + * + * @param index the index value to set. + */ + @Generated + private MessageDeltaTextFileCitationAnnotation(int index) { + super(index); + } + + /** + * Get the type property: The type of the text content annotation. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the fileCitation property: The file citation information. + * + * @return the fileCitation value. + */ + @Generated + public MessageDeltaTextFileCitationAnnotationObject getFileCitation() { + return this.fileCitation; + } + + /** + * Get the text property: The text in the message content that needs to be replaced. + * + * @return the text value. + */ + @Generated + public String getText() { + return this.text; + } + + /** + * Get the startIndex property: The start index of this annotation in the content text. + * + * @return the startIndex value. + */ + @Generated + public Integer getStartIndex() { + return this.startIndex; + } + + /** + * Get the endIndex property: The end index of this annotation in the content text. + * + * @return the endIndex value. + */ + @Generated + public Integer getEndIndex() { + return this.endIndex; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", getIndex()); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("file_citation", this.fileCitation); + jsonWriter.writeStringField("text", this.text); + jsonWriter.writeNumberField("start_index", this.startIndex); + jsonWriter.writeNumberField("end_index", this.endIndex); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaTextFileCitationAnnotation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaTextFileCitationAnnotation if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageDeltaTextFileCitationAnnotation. + */ + @Generated + public static MessageDeltaTextFileCitationAnnotation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String type = "file_citation"; + MessageDeltaTextFileCitationAnnotationObject fileCitation = null; + String text = null; + Integer startIndex = null; + Integer endIndex = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("file_citation".equals(fieldName)) { + fileCitation = MessageDeltaTextFileCitationAnnotationObject.fromJson(reader); + } else if ("text".equals(fieldName)) { + text = reader.getString(); + } else if ("start_index".equals(fieldName)) { + startIndex = reader.getNullable(JsonReader::getInt); + } else if ("end_index".equals(fieldName)) { + endIndex = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + MessageDeltaTextFileCitationAnnotation deserializedMessageDeltaTextFileCitationAnnotation + = new MessageDeltaTextFileCitationAnnotation(index); + deserializedMessageDeltaTextFileCitationAnnotation.type = type; + deserializedMessageDeltaTextFileCitationAnnotation.fileCitation = fileCitation; + deserializedMessageDeltaTextFileCitationAnnotation.text = text; + deserializedMessageDeltaTextFileCitationAnnotation.startIndex = startIndex; + deserializedMessageDeltaTextFileCitationAnnotation.endIndex = endIndex; + return deserializedMessageDeltaTextFileCitationAnnotation; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFileCitationAnnotationObject.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFileCitationAnnotationObject.java new file mode 100644 index 000000000000..ba47afe965d8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFileCitationAnnotationObject.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents the data of a streamed file citation as applied to a streaming text content part. + */ +@Immutable +public final class MessageDeltaTextFileCitationAnnotationObject + implements JsonSerializable { + + /* + * The ID of the specific file the citation is from. + */ + @Generated + private String fileId; + + /* + * The specific quote in the cited file. + */ + @Generated + private String quote; + + /** + * Creates an instance of MessageDeltaTextFileCitationAnnotationObject class. + */ + @Generated + private MessageDeltaTextFileCitationAnnotationObject() { + } + + /** + * Get the fileId property: The ID of the specific file the citation is from. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * Get the quote property: The specific quote in the cited file. + * + * @return the quote value. + */ + @Generated + public String getQuote() { + return this.quote; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + jsonWriter.writeStringField("quote", this.quote); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaTextFileCitationAnnotationObject from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaTextFileCitationAnnotationObject if the JsonReader was pointing to an instance + * of it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the MessageDeltaTextFileCitationAnnotationObject. + */ + @Generated + public static MessageDeltaTextFileCitationAnnotationObject fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageDeltaTextFileCitationAnnotationObject deserializedMessageDeltaTextFileCitationAnnotationObject + = new MessageDeltaTextFileCitationAnnotationObject(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + deserializedMessageDeltaTextFileCitationAnnotationObject.fileId = reader.getString(); + } else if ("quote".equals(fieldName)) { + deserializedMessageDeltaTextFileCitationAnnotationObject.quote = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedMessageDeltaTextFileCitationAnnotationObject; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFilePathAnnotation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFilePathAnnotation.java new file mode 100644 index 000000000000..5215ce985f84 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFilePathAnnotation.java @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a streamed file path annotation applied to a streaming text content part. + */ +@Immutable +public final class MessageDeltaTextFilePathAnnotation extends MessageDeltaTextAnnotation { + + /* + * The type of the text content annotation. + */ + @Generated + private String type = "file_path"; + + /* + * The file path information. + */ + @Generated + private MessageDeltaTextFilePathAnnotationObject filePath; + + /* + * The start index of this annotation in the content text. + */ + @Generated + private Integer startIndex; + + /* + * The end index of this annotation in the content text. + */ + @Generated + private Integer endIndex; + + /* + * The text in the message content that needs to be replaced + */ + @Generated + private String text; + + /** + * Creates an instance of MessageDeltaTextFilePathAnnotation class. + * + * @param index the index value to set. + */ + @Generated + private MessageDeltaTextFilePathAnnotation(int index) { + super(index); + } + + /** + * Get the type property: The type of the text content annotation. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the filePath property: The file path information. + * + * @return the filePath value. + */ + @Generated + public MessageDeltaTextFilePathAnnotationObject getFilePath() { + return this.filePath; + } + + /** + * Get the startIndex property: The start index of this annotation in the content text. + * + * @return the startIndex value. + */ + @Generated + public Integer getStartIndex() { + return this.startIndex; + } + + /** + * Get the endIndex property: The end index of this annotation in the content text. + * + * @return the endIndex value. + */ + @Generated + public Integer getEndIndex() { + return this.endIndex; + } + + /** + * Get the text property: The text in the message content that needs to be replaced. + * + * @return the text value. + */ + @Generated + public String getText() { + return this.text; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", getIndex()); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("file_path", this.filePath); + jsonWriter.writeNumberField("start_index", this.startIndex); + jsonWriter.writeNumberField("end_index", this.endIndex); + jsonWriter.writeStringField("text", this.text); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaTextFilePathAnnotation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaTextFilePathAnnotation if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageDeltaTextFilePathAnnotation. + */ + @Generated + public static MessageDeltaTextFilePathAnnotation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String type = "file_path"; + MessageDeltaTextFilePathAnnotationObject filePath = null; + Integer startIndex = null; + Integer endIndex = null; + String text = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("file_path".equals(fieldName)) { + filePath = MessageDeltaTextFilePathAnnotationObject.fromJson(reader); + } else if ("start_index".equals(fieldName)) { + startIndex = reader.getNullable(JsonReader::getInt); + } else if ("end_index".equals(fieldName)) { + endIndex = reader.getNullable(JsonReader::getInt); + } else if ("text".equals(fieldName)) { + text = reader.getString(); + } else { + reader.skipChildren(); + } + } + MessageDeltaTextFilePathAnnotation deserializedMessageDeltaTextFilePathAnnotation + = new MessageDeltaTextFilePathAnnotation(index); + deserializedMessageDeltaTextFilePathAnnotation.type = type; + deserializedMessageDeltaTextFilePathAnnotation.filePath = filePath; + deserializedMessageDeltaTextFilePathAnnotation.startIndex = startIndex; + deserializedMessageDeltaTextFilePathAnnotation.endIndex = endIndex; + deserializedMessageDeltaTextFilePathAnnotation.text = text; + return deserializedMessageDeltaTextFilePathAnnotation; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFilePathAnnotationObject.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFilePathAnnotationObject.java new file mode 100644 index 000000000000..54c18e1fcaf9 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextFilePathAnnotationObject.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents the data of a streamed file path annotation as applied to a streaming text content part. + */ +@Immutable +public final class MessageDeltaTextFilePathAnnotationObject + implements JsonSerializable { + + /* + * The file ID for the annotation. + */ + @Generated + private String fileId; + + /** + * Creates an instance of MessageDeltaTextFilePathAnnotationObject class. + */ + @Generated + private MessageDeltaTextFilePathAnnotationObject() { + } + + /** + * Get the fileId property: The file ID for the annotation. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaTextFilePathAnnotationObject from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaTextFilePathAnnotationObject if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the MessageDeltaTextFilePathAnnotationObject. + */ + @Generated + public static MessageDeltaTextFilePathAnnotationObject fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageDeltaTextFilePathAnnotationObject deserializedMessageDeltaTextFilePathAnnotationObject + = new MessageDeltaTextFilePathAnnotationObject(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + deserializedMessageDeltaTextFilePathAnnotationObject.fileId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedMessageDeltaTextFilePathAnnotationObject; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextUrlCitationAnnotation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextUrlCitationAnnotation.java new file mode 100644 index 000000000000..0de30e844b33 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextUrlCitationAnnotation.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A citation within the message that points to a specific URL associated with the message. Generated when the agent + * uses tools such as 'bing_grounding' to search the Internet. + */ +@Immutable +public final class MessageDeltaTextUrlCitationAnnotation extends MessageDeltaTextAnnotation { + + /* + * The type of the text content annotation. + */ + @Generated + private String type = "url_citation"; + + /* + * The details of the URL citation. + */ + @Generated + private final MessageDeltaTextUrlCitationDetails urlCitation; + + /* + * The first text index associated with this text annotation. + */ + @Generated + private Integer startIndex; + + /* + * The last text index associated with this text annotation. + */ + @Generated + private Integer endIndex; + + /** + * Creates an instance of MessageDeltaTextUrlCitationAnnotation class. + * + * @param index the index value to set. + * @param urlCitation the urlCitation value to set. + */ + @Generated + private MessageDeltaTextUrlCitationAnnotation(int index, MessageDeltaTextUrlCitationDetails urlCitation) { + super(index); + this.urlCitation = urlCitation; + } + + /** + * Get the type property: The type of the text content annotation. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the urlCitation property: The details of the URL citation. + * + * @return the urlCitation value. + */ + @Generated + public MessageDeltaTextUrlCitationDetails getUrlCitation() { + return this.urlCitation; + } + + /** + * Get the startIndex property: The first text index associated with this text annotation. + * + * @return the startIndex value. + */ + @Generated + public Integer getStartIndex() { + return this.startIndex; + } + + /** + * Get the endIndex property: The last text index associated with this text annotation. + * + * @return the endIndex value. + */ + @Generated + public Integer getEndIndex() { + return this.endIndex; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", getIndex()); + jsonWriter.writeJsonField("url_citation", this.urlCitation); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeNumberField("start_index", this.startIndex); + jsonWriter.writeNumberField("end_index", this.endIndex); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaTextUrlCitationAnnotation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaTextUrlCitationAnnotation if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageDeltaTextUrlCitationAnnotation. + */ + @Generated + public static MessageDeltaTextUrlCitationAnnotation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + MessageDeltaTextUrlCitationDetails urlCitation = null; + String type = "url_citation"; + Integer startIndex = null; + Integer endIndex = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("url_citation".equals(fieldName)) { + urlCitation = MessageDeltaTextUrlCitationDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("start_index".equals(fieldName)) { + startIndex = reader.getNullable(JsonReader::getInt); + } else if ("end_index".equals(fieldName)) { + endIndex = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + MessageDeltaTextUrlCitationAnnotation deserializedMessageDeltaTextUrlCitationAnnotation + = new MessageDeltaTextUrlCitationAnnotation(index, urlCitation); + deserializedMessageDeltaTextUrlCitationAnnotation.type = type; + deserializedMessageDeltaTextUrlCitationAnnotation.startIndex = startIndex; + deserializedMessageDeltaTextUrlCitationAnnotation.endIndex = endIndex; + return deserializedMessageDeltaTextUrlCitationAnnotation; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextUrlCitationDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextUrlCitationDetails.java new file mode 100644 index 000000000000..eea9416f2193 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageDeltaTextUrlCitationDetails.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A representation of a URL citation, as used in text thread message content. + */ +@Immutable +public final class MessageDeltaTextUrlCitationDetails implements JsonSerializable { + + /* + * The URL associated with this citation. + */ + @Generated + private final String url; + + /* + * The title of the URL. + */ + @Generated + private String title; + + /** + * Creates an instance of MessageDeltaTextUrlCitationDetails class. + * + * @param url the url value to set. + */ + @Generated + private MessageDeltaTextUrlCitationDetails(String url) { + this.url = url; + } + + /** + * Get the url property: The URL associated with this citation. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * Get the title property: The title of the URL. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("url", this.url); + jsonWriter.writeStringField("title", this.title); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageDeltaTextUrlCitationDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageDeltaTextUrlCitationDetails if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageDeltaTextUrlCitationDetails. + */ + @Generated + public static MessageDeltaTextUrlCitationDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String url = null; + String title = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("url".equals(fieldName)) { + url = reader.getString(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else { + reader.skipChildren(); + } + } + MessageDeltaTextUrlCitationDetails deserializedMessageDeltaTextUrlCitationDetails + = new MessageDeltaTextUrlCitationDetails(url); + deserializedMessageDeltaTextUrlCitationDetails.title = title; + return deserializedMessageDeltaTextUrlCitationDetails; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileContent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileContent.java new file mode 100644 index 000000000000..976a2a58c486 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileContent.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A representation of image file content in a thread message. + */ +@Immutable +public final class MessageImageFileContent extends MessageContent { + + /* + * The object type. + */ + @Generated + private String type = "image_file"; + + /* + * The image file for this thread message content item. + */ + @Generated + private final MessageImageFileDetails imageFile; + + /** + * Creates an instance of MessageImageFileContent class. + * + * @param imageFile the imageFile value to set. + */ + @Generated + private MessageImageFileContent(MessageImageFileDetails imageFile) { + this.imageFile = imageFile; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the imageFile property: The image file for this thread message content item. + * + * @return the imageFile value. + */ + @Generated + public MessageImageFileDetails getImageFile() { + return this.imageFile; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("image_file", this.imageFile); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageImageFileContent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageImageFileContent if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageImageFileContent. + */ + @Generated + public static MessageImageFileContent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageImageFileDetails imageFile = null; + String type = "image_file"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("image_file".equals(fieldName)) { + imageFile = MessageImageFileDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + MessageImageFileContent deserializedMessageImageFileContent = new MessageImageFileContent(imageFile); + deserializedMessageImageFileContent.type = type; + return deserializedMessageImageFileContent; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileDetails.java new file mode 100644 index 000000000000..5a0d1050a0e1 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileDetails.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An image reference, as represented in thread message content. + */ +@Immutable +public final class MessageImageFileDetails implements JsonSerializable { + + /* + * The ID for the file associated with this image. + */ + @Generated + private final String fileId; + + /** + * Creates an instance of MessageImageFileDetails class. + * + * @param fileId the fileId value to set. + */ + @Generated + private MessageImageFileDetails(String fileId) { + this.fileId = fileId; + } + + /** + * Get the fileId property: The ID for the file associated with this image. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageImageFileDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageImageFileDetails if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageImageFileDetails. + */ + @Generated + public static MessageImageFileDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String fileId = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + fileId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new MessageImageFileDetails(fileId); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileParam.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileParam.java new file mode 100644 index 000000000000..4bd6e4f05f71 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageFileParam.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines how an internally uploaded image file is referenced when creating an image-file block. + */ +@Fluent +public final class MessageImageFileParam implements JsonSerializable { + + /* + * The ID of the previously uploaded image file. + */ + @Generated + private final String fileId; + + /* + * Optional detail level for the image (auto, low, or high). + */ + @Generated + private ImageDetailLevel detail; + + /** + * Creates an instance of MessageImageFileParam class. + * + * @param fileId the fileId value to set. + */ + @Generated + public MessageImageFileParam(String fileId) { + this.fileId = fileId; + } + + /** + * Get the fileId property: The ID of the previously uploaded image file. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * Get the detail property: Optional detail level for the image (auto, low, or high). + * + * @return the detail value. + */ + @Generated + public ImageDetailLevel getDetail() { + return this.detail; + } + + /** + * Set the detail property: Optional detail level for the image (auto, low, or high). + * + * @param detail the detail value to set. + * @return the MessageImageFileParam object itself. + */ + @Generated + public MessageImageFileParam setDetail(ImageDetailLevel detail) { + this.detail = detail; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + jsonWriter.writeStringField("detail", this.detail == null ? null : this.detail.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageImageFileParam from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageImageFileParam if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageImageFileParam. + */ + @Generated + public static MessageImageFileParam fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String fileId = null; + ImageDetailLevel detail = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + fileId = reader.getString(); + } else if ("detail".equals(fieldName)) { + detail = ImageDetailLevel.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + MessageImageFileParam deserializedMessageImageFileParam = new MessageImageFileParam(fileId); + deserializedMessageImageFileParam.detail = detail; + return deserializedMessageImageFileParam; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageUrlParam.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageUrlParam.java new file mode 100644 index 000000000000..8879291fe718 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageImageUrlParam.java @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines how an external image URL is referenced when creating an image-URL block. + */ +@Fluent +public final class MessageImageUrlParam implements JsonSerializable { + + /* + * The publicly accessible URL of the external image. + */ + @Generated + private final String url; + + /* + * Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. + */ + @Generated + private ImageDetailLevel detail; + + /** + * Creates an instance of MessageImageUrlParam class. + * + * @param url the url value to set. + */ + @Generated + public MessageImageUrlParam(String url) { + this.url = url; + } + + /** + * Get the url property: The publicly accessible URL of the external image. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * Get the detail property: Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not + * specified. + * + * @return the detail value. + */ + @Generated + public ImageDetailLevel getDetail() { + return this.detail; + } + + /** + * Set the detail property: Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not + * specified. + * + * @param detail the detail value to set. + * @return the MessageImageUrlParam object itself. + */ + @Generated + public MessageImageUrlParam setDetail(ImageDetailLevel detail) { + this.detail = detail; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("url", this.url); + jsonWriter.writeStringField("detail", this.detail == null ? null : this.detail.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageImageUrlParam from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageImageUrlParam if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageImageUrlParam. + */ + @Generated + public static MessageImageUrlParam fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String url = null; + ImageDetailLevel detail = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("url".equals(fieldName)) { + url = reader.getString(); + } else if ("detail".equals(fieldName)) { + detail = ImageDetailLevel.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + MessageImageUrlParam deserializedMessageImageUrlParam = new MessageImageUrlParam(url); + deserializedMessageImageUrlParam.detail = detail; + return deserializedMessageImageUrlParam; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageIncompleteDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageIncompleteDetails.java new file mode 100644 index 000000000000..99b963098625 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageIncompleteDetails.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Information providing additional detail about a message entering an incomplete status. + */ +@Immutable +public final class MessageIncompleteDetails implements JsonSerializable { + + /* + * The provided reason describing why the message was marked as incomplete. + */ + @Generated + private final MessageIncompleteDetailsReason reason; + + /** + * Creates an instance of MessageIncompleteDetails class. + * + * @param reason the reason value to set. + */ + @Generated + private MessageIncompleteDetails(MessageIncompleteDetailsReason reason) { + this.reason = reason; + } + + /** + * Get the reason property: The provided reason describing why the message was marked as incomplete. + * + * @return the reason value. + */ + @Generated + public MessageIncompleteDetailsReason getReason() { + return this.reason; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("reason", this.reason == null ? null : this.reason.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageIncompleteDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageIncompleteDetails if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageIncompleteDetails. + */ + @Generated + public static MessageIncompleteDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageIncompleteDetailsReason reason = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("reason".equals(fieldName)) { + reason = MessageIncompleteDetailsReason.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new MessageIncompleteDetails(reason); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageIncompleteDetailsReason.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageIncompleteDetailsReason.java new file mode 100644 index 000000000000..c4400372ce5c --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageIncompleteDetailsReason.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * A set of reasons describing why a message is marked as incomplete. + */ +public final class MessageIncompleteDetailsReason extends ExpandableStringEnum { + + /** + * The run generating the message was terminated due to content filter flagging. + */ + @Generated + public static final MessageIncompleteDetailsReason CONTENT_FILTER = fromString("content_filter"); + + /** + * The run generating the message exhausted available tokens before completion. + */ + @Generated + public static final MessageIncompleteDetailsReason MAX_TOKENS = fromString("max_tokens"); + + /** + * The run generating the message was cancelled before completion. + */ + @Generated + public static final MessageIncompleteDetailsReason RUN_CANCELLED = fromString("run_cancelled"); + + /** + * The run generating the message failed. + */ + @Generated + public static final MessageIncompleteDetailsReason RUN_FAILED = fromString("run_failed"); + + /** + * The run generating the message expired. + */ + @Generated + public static final MessageIncompleteDetailsReason RUN_EXPIRED = fromString("run_expired"); + + /** + * Creates a new instance of MessageIncompleteDetailsReason value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public MessageIncompleteDetailsReason() { + } + + /** + * Creates or finds a MessageIncompleteDetailsReason from its string representation. + * + * @param name a name to look for. + * @return the corresponding MessageIncompleteDetailsReason. + */ + @Generated + public static MessageIncompleteDetailsReason fromString(String name) { + return fromString(name, MessageIncompleteDetailsReason.class); + } + + /** + * Gets known MessageIncompleteDetailsReason values. + * + * @return known MessageIncompleteDetailsReason values. + */ + @Generated + public static Collection values() { + return values(MessageIncompleteDetailsReason.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputContentBlock.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputContentBlock.java new file mode 100644 index 000000000000..61b23d558d3e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputContentBlock.java @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines a single content block when creating a message. The 'type' field determines whether it is text, an image + * file, or an external image URL, etc. + */ +@Immutable +public class MessageInputContentBlock implements JsonSerializable { + + /* + * Specifies which kind of content block this is (text, image_file, image_url, etc.). + */ + @Generated + private MessageBlockType type = MessageBlockType.fromString("MessageInputContentBlock"); + + /** + * Creates an instance of MessageInputContentBlock class. + */ + @Generated + public MessageInputContentBlock() { + } + + /** + * Get the type property: Specifies which kind of content block this is (text, image_file, image_url, etc.). + * + * @return the type value. + */ + @Generated + public MessageBlockType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageInputContentBlock from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageInputContentBlock if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the MessageInputContentBlock. + */ + @Generated + public static MessageInputContentBlock fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("text".equals(discriminatorValue)) { + return MessageInputTextBlock.fromJson(readerToUse.reset()); + } else if ("image_file".equals(discriminatorValue)) { + return MessageInputImageFileBlock.fromJson(readerToUse.reset()); + } else if ("image_url".equals(discriminatorValue)) { + return MessageInputImageUrlBlock.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static MessageInputContentBlock fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageInputContentBlock deserializedMessageInputContentBlock = new MessageInputContentBlock(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedMessageInputContentBlock.type = MessageBlockType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedMessageInputContentBlock; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputImageFileBlock.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputImageFileBlock.java new file mode 100644 index 000000000000..25e7eb0f69e2 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputImageFileBlock.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An image-file block in a new message, referencing an internally uploaded image by file ID. + */ +@Immutable +public final class MessageInputImageFileBlock extends MessageInputContentBlock { + + /* + * Specifies which kind of content block this is (text, image_file, image_url, etc.). + */ + @Generated + private MessageBlockType type = MessageBlockType.IMAGE_FILE; + + /* + * Information about the referenced image file, including file ID and optional detail level. + */ + @Generated + private final MessageImageFileParam imageFile; + + /** + * Creates an instance of MessageInputImageFileBlock class. + * + * @param imageFile the imageFile value to set. + */ + @Generated + public MessageInputImageFileBlock(MessageImageFileParam imageFile) { + this.imageFile = imageFile; + } + + /** + * Get the type property: Specifies which kind of content block this is (text, image_file, image_url, etc.). + * + * @return the type value. + */ + @Generated + @Override + public MessageBlockType getType() { + return this.type; + } + + /** + * Get the imageFile property: Information about the referenced image file, including file ID and optional detail + * level. + * + * @return the imageFile value. + */ + @Generated + public MessageImageFileParam getImageFile() { + return this.imageFile; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("image_file", this.imageFile); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageInputImageFileBlock from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageInputImageFileBlock if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageInputImageFileBlock. + */ + @Generated + public static MessageInputImageFileBlock fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageImageFileParam imageFile = null; + MessageBlockType type = MessageBlockType.IMAGE_FILE; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("image_file".equals(fieldName)) { + imageFile = MessageImageFileParam.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = MessageBlockType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + MessageInputImageFileBlock deserializedMessageInputImageFileBlock + = new MessageInputImageFileBlock(imageFile); + deserializedMessageInputImageFileBlock.type = type; + return deserializedMessageInputImageFileBlock; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputImageUrlBlock.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputImageUrlBlock.java new file mode 100644 index 000000000000..359bde310df2 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputImageUrlBlock.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An image-URL block in a new message, referencing an external image by URL. + */ +@Immutable +public final class MessageInputImageUrlBlock extends MessageInputContentBlock { + + /* + * Specifies which kind of content block this is (text, image_file, image_url, etc.). + */ + @Generated + private MessageBlockType type = MessageBlockType.IMAGE_URL; + + /* + * Information about the external image URL, including the URL and optional detail level. + */ + @Generated + private final MessageImageUrlParam imageUrl; + + /** + * Creates an instance of MessageInputImageUrlBlock class. + * + * @param imageUrl the imageUrl value to set. + */ + @Generated + public MessageInputImageUrlBlock(MessageImageUrlParam imageUrl) { + this.imageUrl = imageUrl; + } + + /** + * Get the type property: Specifies which kind of content block this is (text, image_file, image_url, etc.). + * + * @return the type value. + */ + @Generated + @Override + public MessageBlockType getType() { + return this.type; + } + + /** + * Get the imageUrl property: Information about the external image URL, including the URL and optional detail level. + * + * @return the imageUrl value. + */ + @Generated + public MessageImageUrlParam getImageUrl() { + return this.imageUrl; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("image_url", this.imageUrl); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageInputImageUrlBlock from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageInputImageUrlBlock if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageInputImageUrlBlock. + */ + @Generated + public static MessageInputImageUrlBlock fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageImageUrlParam imageUrl = null; + MessageBlockType type = MessageBlockType.IMAGE_URL; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("image_url".equals(fieldName)) { + imageUrl = MessageImageUrlParam.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = MessageBlockType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + MessageInputImageUrlBlock deserializedMessageInputImageUrlBlock = new MessageInputImageUrlBlock(imageUrl); + deserializedMessageInputImageUrlBlock.type = type; + return deserializedMessageInputImageUrlBlock; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputTextBlock.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputTextBlock.java new file mode 100644 index 000000000000..a4c0b627ae20 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageInputTextBlock.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A text block in a new message, containing plain text content. + */ +@Immutable +public final class MessageInputTextBlock extends MessageInputContentBlock { + + /* + * Specifies which kind of content block this is (text, image_file, image_url, etc.). + */ + @Generated + private MessageBlockType type = MessageBlockType.TEXT; + + /* + * The plain text content for this block. + */ + @Generated + private final String text; + + /** + * Creates an instance of MessageInputTextBlock class. + * + * @param text the text value to set. + */ + @Generated + public MessageInputTextBlock(String text) { + this.text = text; + } + + /** + * Get the type property: Specifies which kind of content block this is (text, image_file, image_url, etc.). + * + * @return the type value. + */ + @Generated + @Override + public MessageBlockType getType() { + return this.type; + } + + /** + * Get the text property: The plain text content for this block. + * + * @return the text value. + */ + @Generated + public String getText() { + return this.text; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("text", this.text); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageInputTextBlock from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageInputTextBlock if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageInputTextBlock. + */ + @Generated + public static MessageInputTextBlock fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String text = null; + MessageBlockType type = MessageBlockType.TEXT; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("text".equals(fieldName)) { + text = reader.getString(); + } else if ("type".equals(fieldName)) { + type = MessageBlockType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + MessageInputTextBlock deserializedMessageInputTextBlock = new MessageInputTextBlock(text); + deserializedMessageInputTextBlock.type = type; + return deserializedMessageInputTextBlock; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageRole.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageRole.java new file mode 100644 index 000000000000..0e96b697c72f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageRole.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The possible values for roles attributed to messages in a thread. + */ +public final class MessageRole extends ExpandableStringEnum { + + /** + * The role representing the end-user. + */ + @Generated + public static final MessageRole USER = fromString("user"); + + /** + * The role representing the agent. + */ + @Generated + public static final MessageRole AGENT = fromString("assistant"); + + /** + * Creates a new instance of MessageRole value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public MessageRole() { + } + + /** + * Creates or finds a MessageRole from its string representation. + * + * @param name a name to look for. + * @return the corresponding MessageRole. + */ + @Generated + public static MessageRole fromString(String name) { + return fromString(name, MessageRole.class); + } + + /** + * Gets known MessageRole values. + * + * @return known MessageRole values. + */ + @Generated + public static Collection values() { + return values(MessageRole.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageStatus.java new file mode 100644 index 000000000000..58995859841d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageStatus.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The possible execution status values for a thread message. + */ +public final class MessageStatus extends ExpandableStringEnum { + + /** + * A run is currently creating this message. + */ + @Generated + public static final MessageStatus IN_PROGRESS = fromString("in_progress"); + + /** + * This message is incomplete. See incomplete_details for more information. + */ + @Generated + public static final MessageStatus INCOMPLETE = fromString("incomplete"); + + /** + * This message was successfully completed by a run. + */ + @Generated + public static final MessageStatus COMPLETED = fromString("completed"); + + /** + * Creates a new instance of MessageStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public MessageStatus() { + } + + /** + * Creates or finds a MessageStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding MessageStatus. + */ + @Generated + public static MessageStatus fromString(String name) { + return fromString(name, MessageStatus.class); + } + + /** + * Gets known MessageStatus values. + * + * @return known MessageStatus values. + */ + @Generated + public static Collection values() { + return values(MessageStatus.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageStreamEvent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageStreamEvent.java new file mode 100644 index 000000000000..e7bafd438f50 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageStreamEvent.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Message operation related streaming events. + */ +public final class MessageStreamEvent extends ExpandableStringEnum { + + /** + * Event sent when a new message is created. The data of this event is of type ThreadMessage. + */ + @Generated + public static final MessageStreamEvent THREAD_MESSAGE_CREATED = fromString("thread.message.created"); + + /** + * Event sent when a message moves to `in_progress` status. The data of this event is of type ThreadMessage. + */ + @Generated + public static final MessageStreamEvent THREAD_MESSAGE_IN_PROGRESS = fromString("thread.message.in_progress"); + + /** + * Event sent when a message is being streamed. The data of this event is of type MessageDeltaChunk. + */ + @Generated + public static final MessageStreamEvent THREAD_MESSAGE_DELTA = fromString("thread.message.delta"); + + /** + * Event sent when a message is completed. The data of this event is of type ThreadMessage. + */ + @Generated + public static final MessageStreamEvent THREAD_MESSAGE_COMPLETED = fromString("thread.message.completed"); + + /** + * Event sent before a message is completed. The data of this event is of type ThreadMessage. + */ + @Generated + public static final MessageStreamEvent THREAD_MESSAGE_INCOMPLETE = fromString("thread.message.incomplete"); + + /** + * Creates a new instance of MessageStreamEvent value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public MessageStreamEvent() { + } + + /** + * Creates or finds a MessageStreamEvent from its string representation. + * + * @param name a name to look for. + * @return the corresponding MessageStreamEvent. + */ + @Generated + public static MessageStreamEvent fromString(String name) { + return fromString(name, MessageStreamEvent.class); + } + + /** + * Gets known MessageStreamEvent values. + * + * @return known MessageStreamEvent values. + */ + @Generated + public static Collection values() { + return values(MessageStreamEvent.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextAnnotation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextAnnotation.java new file mode 100644 index 000000000000..b0fd673aad22 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextAnnotation.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An abstract representation of an annotation to text thread message content. + */ +@Immutable +public class MessageTextAnnotation implements JsonSerializable { + + /* + * The object type. + */ + @Generated + private String type = "MessageTextAnnotation"; + + /* + * The textual content associated with this text annotation item. + */ + @Generated + private final String text; + + /** + * Creates an instance of MessageTextAnnotation class. + * + * @param text the text value to set. + */ + @Generated + protected MessageTextAnnotation(String text) { + this.text = text; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the text property: The textual content associated with this text annotation item. + * + * @return the text value. + */ + @Generated + public String getText() { + return this.text; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("text", this.text); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageTextAnnotation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageTextAnnotation if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageTextAnnotation. + */ + @Generated + public static MessageTextAnnotation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("url_citation".equals(discriminatorValue)) { + return MessageTextUrlCitationAnnotation.fromJson(readerToUse.reset()); + } else if ("file_citation".equals(discriminatorValue)) { + return MessageTextFileCitationAnnotation.fromJson(readerToUse.reset()); + } else if ("file_path".equals(discriminatorValue)) { + return MessageTextFilePathAnnotation.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static MessageTextAnnotation fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String text = null; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("text".equals(fieldName)) { + text = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + MessageTextAnnotation deserializedMessageTextAnnotation = new MessageTextAnnotation(text); + deserializedMessageTextAnnotation.type = type; + return deserializedMessageTextAnnotation; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextContent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextContent.java new file mode 100644 index 000000000000..7b02d954702c --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextContent.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A representation of a textual item of thread message content. + */ +@Immutable +public final class MessageTextContent extends MessageContent { + + /* + * The object type. + */ + @Generated + private String type = "text"; + + /* + * The text and associated annotations for this thread message content item. + */ + @Generated + private final MessageTextDetails text; + + /** + * Creates an instance of MessageTextContent class. + * + * @param text the text value to set. + */ + @Generated + private MessageTextContent(MessageTextDetails text) { + this.text = text; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the text property: The text and associated annotations for this thread message content item. + * + * @return the text value. + */ + @Generated + public MessageTextDetails getText() { + return this.text; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("text", this.text); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageTextContent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageTextContent if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageTextContent. + */ + @Generated + public static MessageTextContent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageTextDetails text = null; + String type = "text"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("text".equals(fieldName)) { + text = MessageTextDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + MessageTextContent deserializedMessageTextContent = new MessageTextContent(text); + deserializedMessageTextContent.type = type; + return deserializedMessageTextContent; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextDetails.java new file mode 100644 index 000000000000..0562eac8e264 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextDetails.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The text and associated annotations for a single item of agent thread message content. + */ +@Immutable +public final class MessageTextDetails implements JsonSerializable { + + /* + * The text data. + */ + @Generated + private final String value; + + /* + * A list of annotations associated with this text. + */ + @Generated + private final List annotations; + + /** + * Creates an instance of MessageTextDetails class. + * + * @param value the value value to set. + * @param annotations the annotations value to set. + */ + @Generated + private MessageTextDetails(String value, List annotations) { + this.value = value; + this.annotations = annotations; + } + + /** + * Get the value property: The text data. + * + * @return the value value. + */ + @Generated + public String getValue() { + return this.value; + } + + /** + * Get the annotations property: A list of annotations associated with this text. + * + * @return the annotations value. + */ + @Generated + public List getAnnotations() { + return this.annotations; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", this.value); + jsonWriter.writeArrayField("annotations", this.annotations, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageTextDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageTextDetails if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageTextDetails. + */ + @Generated + public static MessageTextDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String value = null; + List annotations = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("value".equals(fieldName)) { + value = reader.getString(); + } else if ("annotations".equals(fieldName)) { + annotations = reader.readArray(reader1 -> MessageTextAnnotation.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new MessageTextDetails(value, annotations); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFileCitationAnnotation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFileCitationAnnotation.java new file mode 100644 index 000000000000..e5fa87fd6880 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFileCitationAnnotation.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A citation within the message that points to a specific quote from a specific File associated with the agent or the + * message. Generated when the agent uses the 'file_search' tool to search files. + */ +@Immutable +public final class MessageTextFileCitationAnnotation extends MessageTextAnnotation { + + /* + * The object type. + */ + @Generated + private String type = "file_citation"; + + /* + * A citation within the message that points to a specific quote from a specific file. + * Generated when the agent uses the "file_search" tool to search files. + */ + @Generated + private final MessageTextFileCitationDetails fileCitation; + + /* + * The first text index associated with this text annotation. + */ + @Generated + private Integer startIndex; + + /* + * The last text index associated with this text annotation. + */ + @Generated + private Integer endIndex; + + /** + * Creates an instance of MessageTextFileCitationAnnotation class. + * + * @param text the text value to set. + * @param fileCitation the fileCitation value to set. + */ + @Generated + private MessageTextFileCitationAnnotation(String text, MessageTextFileCitationDetails fileCitation) { + super(text); + this.fileCitation = fileCitation; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the fileCitation property: A citation within the message that points to a specific quote from a specific + * file. + * Generated when the agent uses the "file_search" tool to search files. + * + * @return the fileCitation value. + */ + @Generated + public MessageTextFileCitationDetails getFileCitation() { + return this.fileCitation; + } + + /** + * Get the startIndex property: The first text index associated with this text annotation. + * + * @return the startIndex value. + */ + @Generated + public Integer getStartIndex() { + return this.startIndex; + } + + /** + * Get the endIndex property: The last text index associated with this text annotation. + * + * @return the endIndex value. + */ + @Generated + public Integer getEndIndex() { + return this.endIndex; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("text", getText()); + jsonWriter.writeJsonField("file_citation", this.fileCitation); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeNumberField("start_index", this.startIndex); + jsonWriter.writeNumberField("end_index", this.endIndex); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageTextFileCitationAnnotation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageTextFileCitationAnnotation if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageTextFileCitationAnnotation. + */ + @Generated + public static MessageTextFileCitationAnnotation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String text = null; + MessageTextFileCitationDetails fileCitation = null; + String type = "file_citation"; + Integer startIndex = null; + Integer endIndex = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("text".equals(fieldName)) { + text = reader.getString(); + } else if ("file_citation".equals(fieldName)) { + fileCitation = MessageTextFileCitationDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("start_index".equals(fieldName)) { + startIndex = reader.getNullable(JsonReader::getInt); + } else if ("end_index".equals(fieldName)) { + endIndex = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + MessageTextFileCitationAnnotation deserializedMessageTextFileCitationAnnotation + = new MessageTextFileCitationAnnotation(text, fileCitation); + deserializedMessageTextFileCitationAnnotation.type = type; + deserializedMessageTextFileCitationAnnotation.startIndex = startIndex; + deserializedMessageTextFileCitationAnnotation.endIndex = endIndex; + return deserializedMessageTextFileCitationAnnotation; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFileCitationDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFileCitationDetails.java new file mode 100644 index 000000000000..96b6c9f0c8f8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFileCitationDetails.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A representation of a file-based text citation, as used in a file-based annotation of text thread message content. + */ +@Immutable +public final class MessageTextFileCitationDetails implements JsonSerializable { + + /* + * The ID of the file associated with this citation. + */ + @Generated + private final String fileId; + + /* + * The specific quote cited in the associated file. + */ + @Generated + private final String quote; + + /** + * Creates an instance of MessageTextFileCitationDetails class. + * + * @param fileId the fileId value to set. + * @param quote the quote value to set. + */ + @Generated + private MessageTextFileCitationDetails(String fileId, String quote) { + this.fileId = fileId; + this.quote = quote; + } + + /** + * Get the fileId property: The ID of the file associated with this citation. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * Get the quote property: The specific quote cited in the associated file. + * + * @return the quote value. + */ + @Generated + public String getQuote() { + return this.quote; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + jsonWriter.writeStringField("quote", this.quote); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageTextFileCitationDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageTextFileCitationDetails if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageTextFileCitationDetails. + */ + @Generated + public static MessageTextFileCitationDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String fileId = null; + String quote = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + fileId = reader.getString(); + } else if ("quote".equals(fieldName)) { + quote = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new MessageTextFileCitationDetails(fileId, quote); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFilePathAnnotation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFilePathAnnotation.java new file mode 100644 index 000000000000..bc77eafc21c9 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFilePathAnnotation.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A citation within the message that points to a file located at a specific path. + */ +@Immutable +public final class MessageTextFilePathAnnotation extends MessageTextAnnotation { + + /* + * The object type. + */ + @Generated + private String type = "file_path"; + + /* + * A URL for the file that's generated when the agent used the code_interpreter tool to generate a file. + */ + @Generated + private final MessageTextFilePathDetails filePath; + + /* + * The first text index associated with this text annotation. + */ + @Generated + private Integer startIndex; + + /* + * The last text index associated with this text annotation. + */ + @Generated + private Integer endIndex; + + /** + * Creates an instance of MessageTextFilePathAnnotation class. + * + * @param text the text value to set. + * @param filePath the filePath value to set. + */ + @Generated + private MessageTextFilePathAnnotation(String text, MessageTextFilePathDetails filePath) { + super(text); + this.filePath = filePath; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the filePath property: A URL for the file that's generated when the agent used the code_interpreter tool to + * generate a file. + * + * @return the filePath value. + */ + @Generated + public MessageTextFilePathDetails getFilePath() { + return this.filePath; + } + + /** + * Get the startIndex property: The first text index associated with this text annotation. + * + * @return the startIndex value. + */ + @Generated + public Integer getStartIndex() { + return this.startIndex; + } + + /** + * Get the endIndex property: The last text index associated with this text annotation. + * + * @return the endIndex value. + */ + @Generated + public Integer getEndIndex() { + return this.endIndex; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("text", getText()); + jsonWriter.writeJsonField("file_path", this.filePath); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeNumberField("start_index", this.startIndex); + jsonWriter.writeNumberField("end_index", this.endIndex); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageTextFilePathAnnotation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageTextFilePathAnnotation if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageTextFilePathAnnotation. + */ + @Generated + public static MessageTextFilePathAnnotation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String text = null; + MessageTextFilePathDetails filePath = null; + String type = "file_path"; + Integer startIndex = null; + Integer endIndex = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("text".equals(fieldName)) { + text = reader.getString(); + } else if ("file_path".equals(fieldName)) { + filePath = MessageTextFilePathDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("start_index".equals(fieldName)) { + startIndex = reader.getNullable(JsonReader::getInt); + } else if ("end_index".equals(fieldName)) { + endIndex = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + MessageTextFilePathAnnotation deserializedMessageTextFilePathAnnotation + = new MessageTextFilePathAnnotation(text, filePath); + deserializedMessageTextFilePathAnnotation.type = type; + deserializedMessageTextFilePathAnnotation.startIndex = startIndex; + deserializedMessageTextFilePathAnnotation.endIndex = endIndex; + return deserializedMessageTextFilePathAnnotation; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFilePathDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFilePathDetails.java new file mode 100644 index 000000000000..148623c5dff4 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextFilePathDetails.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An encapsulation of an image file ID, as used by message image content. + */ +@Immutable +public final class MessageTextFilePathDetails implements JsonSerializable { + + /* + * The ID of the specific file that the citation is from. + */ + @Generated + private final String fileId; + + /** + * Creates an instance of MessageTextFilePathDetails class. + * + * @param fileId the fileId value to set. + */ + @Generated + private MessageTextFilePathDetails(String fileId) { + this.fileId = fileId; + } + + /** + * Get the fileId property: The ID of the specific file that the citation is from. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageTextFilePathDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageTextFilePathDetails if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageTextFilePathDetails. + */ + @Generated + public static MessageTextFilePathDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String fileId = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + fileId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new MessageTextFilePathDetails(fileId); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextUrlCitationAnnotation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextUrlCitationAnnotation.java new file mode 100644 index 000000000000..53c2afc4fdae --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextUrlCitationAnnotation.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A citation within the message that points to a specific URL associated with the message. Generated when the agent + * uses tools such as 'bing_grounding' to search the Internet. + */ +@Immutable +public final class MessageTextUrlCitationAnnotation extends MessageTextAnnotation { + + /* + * The object type. + */ + @Generated + private String type = "url_citation"; + + /* + * The details of the URL citation. + */ + @Generated + private final MessageTextUrlCitationDetails urlCitation; + + /* + * The first text index associated with this text annotation. + */ + @Generated + private Integer startIndex; + + /* + * The last text index associated with this text annotation. + */ + @Generated + private Integer endIndex; + + /** + * Creates an instance of MessageTextUrlCitationAnnotation class. + * + * @param text the text value to set. + * @param urlCitation the urlCitation value to set. + */ + @Generated + private MessageTextUrlCitationAnnotation(String text, MessageTextUrlCitationDetails urlCitation) { + super(text); + this.urlCitation = urlCitation; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the urlCitation property: The details of the URL citation. + * + * @return the urlCitation value. + */ + @Generated + public MessageTextUrlCitationDetails getUrlCitation() { + return this.urlCitation; + } + + /** + * Get the startIndex property: The first text index associated with this text annotation. + * + * @return the startIndex value. + */ + @Generated + public Integer getStartIndex() { + return this.startIndex; + } + + /** + * Get the endIndex property: The last text index associated with this text annotation. + * + * @return the endIndex value. + */ + @Generated + public Integer getEndIndex() { + return this.endIndex; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("text", getText()); + jsonWriter.writeJsonField("url_citation", this.urlCitation); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeNumberField("start_index", this.startIndex); + jsonWriter.writeNumberField("end_index", this.endIndex); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageTextUrlCitationAnnotation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageTextUrlCitationAnnotation if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageTextUrlCitationAnnotation. + */ + @Generated + public static MessageTextUrlCitationAnnotation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String text = null; + MessageTextUrlCitationDetails urlCitation = null; + String type = "url_citation"; + Integer startIndex = null; + Integer endIndex = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("text".equals(fieldName)) { + text = reader.getString(); + } else if ("url_citation".equals(fieldName)) { + urlCitation = MessageTextUrlCitationDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("start_index".equals(fieldName)) { + startIndex = reader.getNullable(JsonReader::getInt); + } else if ("end_index".equals(fieldName)) { + endIndex = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + MessageTextUrlCitationAnnotation deserializedMessageTextUrlCitationAnnotation + = new MessageTextUrlCitationAnnotation(text, urlCitation); + deserializedMessageTextUrlCitationAnnotation.type = type; + deserializedMessageTextUrlCitationAnnotation.startIndex = startIndex; + deserializedMessageTextUrlCitationAnnotation.endIndex = endIndex; + return deserializedMessageTextUrlCitationAnnotation; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextUrlCitationDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextUrlCitationDetails.java new file mode 100644 index 000000000000..0844ac823475 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MessageTextUrlCitationDetails.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A representation of a URL citation, as used in text thread message content. + */ +@Immutable +public final class MessageTextUrlCitationDetails implements JsonSerializable { + + /* + * The URL associated with this citation. + */ + @Generated + private final String url; + + /* + * The title of the URL. + */ + @Generated + private String title; + + /** + * Creates an instance of MessageTextUrlCitationDetails class. + * + * @param url the url value to set. + */ + @Generated + private MessageTextUrlCitationDetails(String url) { + this.url = url; + } + + /** + * Get the url property: The URL associated with this citation. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * Get the title property: The title of the URL. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("url", this.url); + jsonWriter.writeStringField("title", this.title); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MessageTextUrlCitationDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MessageTextUrlCitationDetails if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MessageTextUrlCitationDetails. + */ + @Generated + public static MessageTextUrlCitationDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String url = null; + String title = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("url".equals(fieldName)) { + url = reader.getString(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else { + reader.skipChildren(); + } + } + MessageTextUrlCitationDetails deserializedMessageTextUrlCitationDetails + = new MessageTextUrlCitationDetails(url); + deserializedMessageTextUrlCitationDetails.title = title; + return deserializedMessageTextUrlCitationDetails; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MicrosoftFabricToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MicrosoftFabricToolDefinition.java new file mode 100644 index 000000000000..1ffe075c4b0b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MicrosoftFabricToolDefinition.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for a Microsoft Fabric tool as used to configure an agent. + */ +@Immutable +public final class MicrosoftFabricToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "fabric_dataagent"; + + /* + * The list of connections used by the Microsoft Fabric tool. + */ + @Generated + private final ToolConnectionList fabricDataagent; + + /** + * Creates an instance of MicrosoftFabricToolDefinition class. + * + * @param fabricDataagent the fabricDataagent value to set. + */ + @Generated + public MicrosoftFabricToolDefinition(ToolConnectionList fabricDataagent) { + this.fabricDataagent = fabricDataagent; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the fabricDataagent property: The list of connections used by the Microsoft Fabric tool. + * + * @return the fabricDataagent value. + */ + @Generated + public ToolConnectionList getFabricDataagent() { + return this.fabricDataagent; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("fabric_dataagent", this.fabricDataagent); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MicrosoftFabricToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MicrosoftFabricToolDefinition if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the MicrosoftFabricToolDefinition. + */ + @Generated + public static MicrosoftFabricToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ToolConnectionList fabricDataagent = null; + String type = "fabric_dataagent"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("fabric_dataagent".equals(fieldName)) { + fabricDataagent = ToolConnectionList.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + MicrosoftFabricToolDefinition deserializedMicrosoftFabricToolDefinition + = new MicrosoftFabricToolDefinition(fabricDataagent); + deserializedMicrosoftFabricToolDefinition.type = type; + return deserializedMicrosoftFabricToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAnonymousAuthDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAnonymousAuthDetails.java new file mode 100644 index 000000000000..a10bfa47b10e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAnonymousAuthDetails.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Security details for OpenApi anonymous authentication. + */ +@Immutable +public final class OpenApiAnonymousAuthDetails extends OpenApiAuthDetails { + + /* + * The type of authentication, must be anonymous/connection/managed_identity + */ + @Generated + private OpenApiAuthType type = OpenApiAuthType.ANONYMOUS; + + /** + * Creates an instance of OpenApiAnonymousAuthDetails class. + */ + @Generated + public OpenApiAnonymousAuthDetails() { + } + + /** + * Get the type property: The type of authentication, must be anonymous/connection/managed_identity. + * + * @return the type value. + */ + @Generated + @Override + public OpenApiAuthType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OpenApiAnonymousAuthDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OpenApiAnonymousAuthDetails if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the OpenApiAnonymousAuthDetails. + */ + @Generated + public static OpenApiAnonymousAuthDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OpenApiAnonymousAuthDetails deserializedOpenApiAnonymousAuthDetails = new OpenApiAnonymousAuthDetails(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedOpenApiAnonymousAuthDetails.type = OpenApiAuthType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedOpenApiAnonymousAuthDetails; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAuthDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAuthDetails.java new file mode 100644 index 000000000000..2c5c1743043a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAuthDetails.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * authentication details for OpenApiFunctionDefinition. + */ +@Immutable +public class OpenApiAuthDetails implements JsonSerializable { + + /* + * The type of authentication, must be anonymous/connection/managed_identity + */ + @Generated + private OpenApiAuthType type = OpenApiAuthType.fromString("OpenApiAuthDetails"); + + /** + * Creates an instance of OpenApiAuthDetails class. + */ + @Generated + public OpenApiAuthDetails() { + } + + /** + * Get the type property: The type of authentication, must be anonymous/connection/managed_identity. + * + * @return the type value. + */ + @Generated + public OpenApiAuthType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OpenApiAuthDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OpenApiAuthDetails if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OpenApiAuthDetails. + */ + @Generated + public static OpenApiAuthDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("anonymous".equals(discriminatorValue)) { + return OpenApiAnonymousAuthDetails.fromJson(readerToUse.reset()); + } else if ("connection".equals(discriminatorValue)) { + return OpenApiConnectionAuthDetails.fromJson(readerToUse.reset()); + } else if ("managed_identity".equals(discriminatorValue)) { + return OpenApiManagedAuthDetails.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static OpenApiAuthDetails fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OpenApiAuthDetails deserializedOpenApiAuthDetails = new OpenApiAuthDetails(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedOpenApiAuthDetails.type = OpenApiAuthType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedOpenApiAuthDetails; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAuthType.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAuthType.java new file mode 100644 index 000000000000..035cdc057f8f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiAuthType.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Authentication type for OpenApi endpoint. Allowed types are: + * - Anonymous (no authentication required) + * - Connection (requires connection_id to endpoint, as setup in AI Foundry) + * - Managed_Identity (requires audience for identity based auth). + */ +public final class OpenApiAuthType extends ExpandableStringEnum { + + /** + * Static value anonymous for OpenApiAuthType. + */ + @Generated + public static final OpenApiAuthType ANONYMOUS = fromString("anonymous"); + + /** + * Static value connection for OpenApiAuthType. + */ + @Generated + public static final OpenApiAuthType CONNECTION = fromString("connection"); + + /** + * Static value managed_identity for OpenApiAuthType. + */ + @Generated + public static final OpenApiAuthType MANAGED_IDENTITY = fromString("managed_identity"); + + /** + * Creates a new instance of OpenApiAuthType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OpenApiAuthType() { + } + + /** + * Creates or finds a OpenApiAuthType from its string representation. + * + * @param name a name to look for. + * @return the corresponding OpenApiAuthType. + */ + @Generated + public static OpenApiAuthType fromString(String name) { + return fromString(name, OpenApiAuthType.class); + } + + /** + * Gets known OpenApiAuthType values. + * + * @return known OpenApiAuthType values. + */ + @Generated + public static Collection values() { + return values(OpenApiAuthType.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiConnectionAuthDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiConnectionAuthDetails.java new file mode 100644 index 000000000000..1dbb0f4fe785 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiConnectionAuthDetails.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Security details for OpenApi connection authentication. + */ +@Immutable +public final class OpenApiConnectionAuthDetails extends OpenApiAuthDetails { + + /* + * The type of authentication, must be anonymous/connection/managed_identity + */ + @Generated + private OpenApiAuthType type = OpenApiAuthType.CONNECTION; + + /* + * Connection auth security details + */ + @Generated + private final OpenApiConnectionSecurityScheme securityScheme; + + /** + * Creates an instance of OpenApiConnectionAuthDetails class. + * + * @param securityScheme the securityScheme value to set. + */ + @Generated + public OpenApiConnectionAuthDetails(OpenApiConnectionSecurityScheme securityScheme) { + this.securityScheme = securityScheme; + } + + /** + * Get the type property: The type of authentication, must be anonymous/connection/managed_identity. + * + * @return the type value. + */ + @Generated + @Override + public OpenApiAuthType getType() { + return this.type; + } + + /** + * Get the securityScheme property: Connection auth security details. + * + * @return the securityScheme value. + */ + @Generated + public OpenApiConnectionSecurityScheme getSecurityScheme() { + return this.securityScheme; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("security_scheme", this.securityScheme); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OpenApiConnectionAuthDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OpenApiConnectionAuthDetails if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OpenApiConnectionAuthDetails. + */ + @Generated + public static OpenApiConnectionAuthDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OpenApiConnectionSecurityScheme securityScheme = null; + OpenApiAuthType type = OpenApiAuthType.CONNECTION; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("security_scheme".equals(fieldName)) { + securityScheme = OpenApiConnectionSecurityScheme.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = OpenApiAuthType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + OpenApiConnectionAuthDetails deserializedOpenApiConnectionAuthDetails + = new OpenApiConnectionAuthDetails(securityScheme); + deserializedOpenApiConnectionAuthDetails.type = type; + return deserializedOpenApiConnectionAuthDetails; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiConnectionSecurityScheme.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiConnectionSecurityScheme.java new file mode 100644 index 000000000000..f34259be62e1 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiConnectionSecurityScheme.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Security scheme for OpenApi managed_identity authentication. + */ +@Immutable +public final class OpenApiConnectionSecurityScheme implements JsonSerializable { + + /* + * Connection id for Connection auth type + */ + @Generated + private final String connectionId; + + /** + * Creates an instance of OpenApiConnectionSecurityScheme class. + * + * @param connectionId the connectionId value to set. + */ + @Generated + public OpenApiConnectionSecurityScheme(String connectionId) { + this.connectionId = connectionId; + } + + /** + * Get the connectionId property: Connection id for Connection auth type. + * + * @return the connectionId value. + */ + @Generated + public String getConnectionId() { + return this.connectionId; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("connection_id", this.connectionId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OpenApiConnectionSecurityScheme from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OpenApiConnectionSecurityScheme if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OpenApiConnectionSecurityScheme. + */ + @Generated + public static OpenApiConnectionSecurityScheme fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String connectionId = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("connection_id".equals(fieldName)) { + connectionId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new OpenApiConnectionSecurityScheme(connectionId); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiFunctionDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiFunctionDefinition.java new file mode 100644 index 000000000000..69c60c5491da --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiFunctionDefinition.java @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The input definition information for an openapi function. + */ +@Fluent +public final class OpenApiFunctionDefinition implements JsonSerializable { + + /* + * The name of the function to be called. + */ + @Generated + private final String name; + + /* + * A description of what the function does, used by the model to choose when and how to call the function. + */ + @Generated + private String description; + + /* + * The openapi function shape, described as a JSON Schema object. + */ + @Generated + private final BinaryData spec; + + /* + * Open API authentication details + */ + @Generated + private final OpenApiAuthDetails auth; + + /* + * List of OpenAPI spec parameters that will use user-provided defaults + */ + @Generated + private List defaultParams; + + /** + * Creates an instance of OpenApiFunctionDefinition class. + * + * @param name the name value to set. + * @param spec the spec value to set. + * @param auth the auth value to set. + */ + @Generated + public OpenApiFunctionDefinition(String name, BinaryData spec, OpenApiAuthDetails auth) { + this.name = name; + this.spec = spec; + this.auth = auth; + } + + /** + * Get the name property: The name of the function to be called. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the description property: A description of what the function does, used by the model to choose when and how + * to call the function. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: A description of what the function does, used by the model to choose when and how + * to call the function. + * + * @param description the description value to set. + * @return the OpenApiFunctionDefinition object itself. + */ + @Generated + public OpenApiFunctionDefinition setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the spec property: The openapi function shape, described as a JSON Schema object. + * + * @return the spec value. + */ + @Generated + public BinaryData getSpec() { + return this.spec; + } + + /** + * Get the auth property: Open API authentication details. + * + * @return the auth value. + */ + @Generated + public OpenApiAuthDetails getAuth() { + return this.auth; + } + + /** + * Get the defaultParams property: List of OpenAPI spec parameters that will use user-provided defaults. + * + * @return the defaultParams value. + */ + @Generated + public List getDefaultParams() { + return this.defaultParams; + } + + /** + * Set the defaultParams property: List of OpenAPI spec parameters that will use user-provided defaults. + * + * @param defaultParams the defaultParams value to set. + * @return the OpenApiFunctionDefinition object itself. + */ + @Generated + public OpenApiFunctionDefinition setDefaultParams(List defaultParams) { + this.defaultParams = defaultParams; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeFieldName("spec"); + this.spec.writeTo(jsonWriter); + jsonWriter.writeJsonField("auth", this.auth); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeArrayField("default_params", this.defaultParams, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OpenApiFunctionDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OpenApiFunctionDefinition if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OpenApiFunctionDefinition. + */ + @Generated + public static OpenApiFunctionDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + BinaryData spec = null; + OpenApiAuthDetails auth = null; + String description = null; + List defaultParams = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("spec".equals(fieldName)) { + spec = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("auth".equals(fieldName)) { + auth = OpenApiAuthDetails.fromJson(reader); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("default_params".equals(fieldName)) { + defaultParams = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + OpenApiFunctionDefinition deserializedOpenApiFunctionDefinition + = new OpenApiFunctionDefinition(name, spec, auth); + deserializedOpenApiFunctionDefinition.description = description; + deserializedOpenApiFunctionDefinition.defaultParams = defaultParams; + return deserializedOpenApiFunctionDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiManagedAuthDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiManagedAuthDetails.java new file mode 100644 index 000000000000..51833d1c9ec6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiManagedAuthDetails.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Security details for OpenApi managed_identity authentication. + */ +@Immutable +public final class OpenApiManagedAuthDetails extends OpenApiAuthDetails { + + /* + * The type of authentication, must be anonymous/connection/managed_identity + */ + @Generated + private OpenApiAuthType type = OpenApiAuthType.MANAGED_IDENTITY; + + /* + * Connection auth security details + */ + @Generated + private final OpenApiManagedSecurityScheme securityScheme; + + /** + * Creates an instance of OpenApiManagedAuthDetails class. + * + * @param securityScheme the securityScheme value to set. + */ + @Generated + public OpenApiManagedAuthDetails(OpenApiManagedSecurityScheme securityScheme) { + this.securityScheme = securityScheme; + } + + /** + * Get the type property: The type of authentication, must be anonymous/connection/managed_identity. + * + * @return the type value. + */ + @Generated + @Override + public OpenApiAuthType getType() { + return this.type; + } + + /** + * Get the securityScheme property: Connection auth security details. + * + * @return the securityScheme value. + */ + @Generated + public OpenApiManagedSecurityScheme getSecurityScheme() { + return this.securityScheme; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("security_scheme", this.securityScheme); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OpenApiManagedAuthDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OpenApiManagedAuthDetails if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OpenApiManagedAuthDetails. + */ + @Generated + public static OpenApiManagedAuthDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OpenApiManagedSecurityScheme securityScheme = null; + OpenApiAuthType type = OpenApiAuthType.MANAGED_IDENTITY; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("security_scheme".equals(fieldName)) { + securityScheme = OpenApiManagedSecurityScheme.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = OpenApiAuthType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + OpenApiManagedAuthDetails deserializedOpenApiManagedAuthDetails + = new OpenApiManagedAuthDetails(securityScheme); + deserializedOpenApiManagedAuthDetails.type = type; + return deserializedOpenApiManagedAuthDetails; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiManagedSecurityScheme.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiManagedSecurityScheme.java new file mode 100644 index 000000000000..0a32aff1d8b0 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiManagedSecurityScheme.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Security scheme for OpenApi managed_identity authentication. + */ +@Immutable +public final class OpenApiManagedSecurityScheme implements JsonSerializable { + + /* + * Authentication scope for managed_identity auth type + */ + @Generated + private final String audience; + + /** + * Creates an instance of OpenApiManagedSecurityScheme class. + * + * @param audience the audience value to set. + */ + @Generated + public OpenApiManagedSecurityScheme(String audience) { + this.audience = audience; + } + + /** + * Get the audience property: Authentication scope for managed_identity auth type. + * + * @return the audience value. + */ + @Generated + public String getAudience() { + return this.audience; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("audience", this.audience); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OpenApiManagedSecurityScheme from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OpenApiManagedSecurityScheme if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OpenApiManagedSecurityScheme. + */ + @Generated + public static OpenApiManagedSecurityScheme fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String audience = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("audience".equals(fieldName)) { + audience = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new OpenApiManagedSecurityScheme(audience); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiToolDefinition.java new file mode 100644 index 000000000000..a0787f7d176f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiToolDefinition.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for an OpenAPI tool as used to configure an agent. + */ +@Immutable +public final class OpenApiToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "openapi"; + + /* + * The openapi function definition. + */ + @Generated + private final OpenApiFunctionDefinition openapi; + + /** + * Creates an instance of OpenApiToolDefinition class. + * + * @param openapi the openapi value to set. + */ + @Generated + public OpenApiToolDefinition(OpenApiFunctionDefinition openapi) { + this.openapi = openapi; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the openapi property: The openapi function definition. + * + * @return the openapi value. + */ + @Generated + public OpenApiFunctionDefinition getOpenapi() { + return this.openapi; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("openapi", this.openapi); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OpenApiToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OpenApiToolDefinition if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OpenApiToolDefinition. + */ + @Generated + public static OpenApiToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OpenApiFunctionDefinition openapi = null; + String type = "openapi"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("openapi".equals(fieldName)) { + openapi = OpenApiFunctionDefinition.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + OpenApiToolDefinition deserializedOpenApiToolDefinition = new OpenApiToolDefinition(openapi); + deserializedOpenApiToolDefinition.type = type; + return deserializedOpenApiToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgent.java new file mode 100644 index 000000000000..255c9f60f77a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgent.java @@ -0,0 +1,377 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; +import java.util.Map; + +/** + * Represents an agent that can call the model and use tools. + */ +@Immutable +public final class PersistentAgent implements JsonSerializable { + + /* + * The identifier, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The object type, which is always assistant. + */ + @Generated + private final String object = "assistant"; + + /* + * The Unix timestamp, in seconds, representing when this object was created. + */ + @Generated + private final long createdAt; + + /* + * The name of the agent. + */ + @Generated + private final String name; + + /* + * The description of the agent. + */ + @Generated + private final String description; + + /* + * The ID of the model to use. + */ + @Generated + private final String model; + + /* + * The system instructions for the agent to use. + */ + @Generated + private final String instructions; + + /* + * The collection of tools enabled for the agent. + */ + @Generated + private final List tools; + + /* + * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For + * example, the `code_interpreter` + * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + */ + @Generated + private final ToolResources toolResources; + + /* + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + */ + @Generated + private final Double temperature; + + /* + * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of + * the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + */ + @Generated + private final Double topP; + + /* + * The response format of the tool calls used by this agent. + */ + @Generated + private BinaryData responseFormat; + + /* + * 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. + */ + @Generated + private final Map metadata; + + /** + * Creates an instance of PersistentAgent class. + * + * @param id the id value to set. + * @param createdAt the createdAt value to set. + * @param name the name value to set. + * @param description the description value to set. + * @param model the model value to set. + * @param instructions the instructions value to set. + * @param tools the tools value to set. + * @param toolResources the toolResources value to set. + * @param temperature the temperature value to set. + * @param topP the topP value to set. + * @param metadata the metadata value to set. + */ + @Generated + private PersistentAgent(String id, OffsetDateTime createdAt, String name, String description, String model, + String instructions, List tools, ToolResources toolResources, Double temperature, Double topP, + Map metadata) { + this.id = id; + if (createdAt == null) { + this.createdAt = 0L; + } else { + this.createdAt = createdAt.toEpochSecond(); + } + this.name = name; + this.description = description; + this.model = model; + this.instructions = instructions; + this.tools = tools; + this.toolResources = toolResources; + this.temperature = temperature; + this.topP = topP; + this.metadata = metadata; + } + + /** + * Get the id property: The identifier, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the object property: The object type, which is always assistant. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the createdAt property: The Unix timestamp, in seconds, representing when this object was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC); + } + + /** + * Get the name property: The name of the agent. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the description property: The description of the agent. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Get the model property: The ID of the model to use. + * + * @return the model value. + */ + @Generated + public String getModel() { + return this.model; + } + + /** + * Get the instructions property: The system instructions for the agent to use. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Get the tools property: The collection of tools enabled for the agent. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * Get the toolResources property: A set of resources that are used by the agent's tools. The resources are specific + * to the type of tool. For example, the `code_interpreter` + * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * + * @return the toolResources value. + */ + @Generated + public ToolResources getToolResources() { + return this.toolResources; + } + + /** + * Get the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + * + * @return the temperature value. + */ + @Generated + public Double getTemperature() { + return this.temperature; + } + + /** + * Get the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @return the topP value. + */ + @Generated + public Double getTopP() { + return this.topP; + } + + /** + * Get the responseFormat property: The response format of the tool calls used by this agent. + * + * @return the responseFormat value. + */ + @Generated + public BinaryData getResponseFormat() { + return this.responseFormat; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeLongField("created_at", this.createdAt); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("model", this.model); + jsonWriter.writeStringField("instructions", this.instructions); + jsonWriter.writeArrayField("tools", this.tools, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("tool_resources", this.toolResources); + jsonWriter.writeNumberField("temperature", this.temperature); + jsonWriter.writeNumberField("top_p", this.topP); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + if (this.responseFormat != null) { + jsonWriter.writeFieldName("response_format"); + this.responseFormat.writeTo(jsonWriter); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersistentAgent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersistentAgent if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PersistentAgent. + */ + @Generated + public static PersistentAgent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OffsetDateTime createdAt = null; + String name = null; + String description = null; + String model = null; + String instructions = null; + List tools = null; + ToolResources toolResources = null; + Double temperature = null; + Double topP = null; + Map metadata = null; + BinaryData responseFormat = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("created_at".equals(fieldName)) { + createdAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader.getLong()), ZoneOffset.UTC); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("model".equals(fieldName)) { + model = reader.getString(); + } else if ("instructions".equals(fieldName)) { + instructions = reader.getString(); + } else if ("tools".equals(fieldName)) { + tools = reader.readArray(reader1 -> ToolDefinition.fromJson(reader1)); + } else if ("tool_resources".equals(fieldName)) { + toolResources = ToolResources.fromJson(reader); + } else if ("temperature".equals(fieldName)) { + temperature = reader.getNullable(JsonReader::getDouble); + } else if ("top_p".equals(fieldName)) { + topP = reader.getNullable(JsonReader::getDouble); + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else if ("response_format".equals(fieldName)) { + responseFormat + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + PersistentAgent deserializedPersistentAgent = new PersistentAgent(id, createdAt, name, description, model, + instructions, tools, toolResources, temperature, topP, metadata); + deserializedPersistentAgent.responseFormat = responseFormat; + return deserializedPersistentAgent; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentStreamEvent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentStreamEvent.java new file mode 100644 index 000000000000..1050dab8d867 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentStreamEvent.java @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Each event in a server-sent events stream has an `event` and `data` property: + * + * ``` + * event: thread.created + * data: {"id": "thread_123", "object": "thread", ...} + * ``` + * + * We emit events whenever a new object is created, transitions to a new state, or is being + * streamed in parts (deltas). For example, we emit `thread.run.created` when a new run + * is created, `thread.run.completed` when a run completes, and so on. When an Agent chooses + * to create a message during a run, we emit a `thread.message.created event`, a + * `thread.message.in_progress` event, many `thread.message.delta` events, and finally a + * `thread.message.completed` event. + * + * We may add additional events over time, so we recommend handling unknown events gracefully + * in your code. + */ +public final class PersistentAgentStreamEvent extends ExpandableStringEnum { + + /** + * Event sent when a new thread is created. The data of this event is of type AgentThread. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_CREATED = fromString("thread.created"); + + /** + * Event sent when a new run is created. The data of this event is of type ThreadRun. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_CREATED = fromString("thread.run.created"); + + /** + * Event sent when a run moves to `queued` status. The data of this event is of type ThreadRun. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_QUEUED = fromString("thread.run.queued"); + + /** + * Event sent when a run moves to `in_progress` status. The data of this event is of type ThreadRun. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_IN_PROGRESS = fromString("thread.run.in_progress"); + + /** + * Event sent when a run moves to `requires_action` status. The data of this event is of type ThreadRun. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_REQUIRES_ACTION + = fromString("thread.run.requires_action"); + + /** + * Event sent when a run is completed. The data of this event is of type ThreadRun. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_COMPLETED = fromString("thread.run.completed"); + + /** + * Event sent when a run ends incomplete. The data of this event is of type ThreadRun. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_INCOMPLETE = fromString("thread.run.incomplete"); + + /** + * Event sent when a run fails. The data of this event is of type ThreadRun. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_FAILED = fromString("thread.run.failed"); + + /** + * Event sent when a run moves to `cancelling` status. The data of this event is of type ThreadRun. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_CANCELLING = fromString("thread.run.cancelling"); + + /** + * Event sent when a run is cancelled. The data of this event is of type ThreadRun. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_CANCELLED = fromString("thread.run.cancelled"); + + /** + * Event sent when a run is expired. The data of this event is of type ThreadRun. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_EXPIRED = fromString("thread.run.expired"); + + /** + * Event sent when a new thread run step is created. The data of this event is of type RunStep. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_STEP_CREATED = fromString("thread.run.step.created"); + + /** + * Event sent when a run step moves to `in_progress` status. The data of this event is of type RunStep. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_STEP_IN_PROGRESS + = fromString("thread.run.step.in_progress"); + + /** + * Event sent when a run step is being streamed. The data of this event is of type RunStepDeltaChunk. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_STEP_DELTA = fromString("thread.run.step.delta"); + + /** + * Event sent when a run step is completed. The data of this event is of type RunStep. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_STEP_COMPLETED = fromString("thread.run.step.completed"); + + /** + * Event sent when a run step fails. The data of this event is of type RunStep. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_STEP_FAILED = fromString("thread.run.step.failed"); + + /** + * Event sent when a run step is cancelled. The data of this event is of type RunStep. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_STEP_CANCELLED = fromString("thread.run.step.cancelled"); + + /** + * Event sent when a run step is expired. The data of this event is of type RunStep. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_RUN_STEP_EXPIRED = fromString("thread.run.step.expired"); + + /** + * Event sent when a new message is created. The data of this event is of type ThreadMessage. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_MESSAGE_CREATED = fromString("thread.message.created"); + + /** + * Event sent when a message moves to `in_progress` status. The data of this event is of type ThreadMessage. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_MESSAGE_IN_PROGRESS + = fromString("thread.message.in_progress"); + + /** + * Event sent when a message is being streamed. The data of this event is of type MessageDeltaChunk. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_MESSAGE_DELTA = fromString("thread.message.delta"); + + /** + * Event sent when a message is completed. The data of this event is of type ThreadMessage. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_MESSAGE_COMPLETED = fromString("thread.message.completed"); + + /** + * Event sent before a message is completed. The data of this event is of type ThreadMessage. + */ + @Generated + public static final PersistentAgentStreamEvent THREAD_MESSAGE_INCOMPLETE = fromString("thread.message.incomplete"); + + /** + * Event sent when an error occurs, such as an internal server error or a timeout. + */ + @Generated + public static final PersistentAgentStreamEvent ERROR = fromString("error"); + + /** + * Event sent when the stream is done. + */ + @Generated + public static final PersistentAgentStreamEvent DONE = fromString("done"); + + /** + * Creates a new instance of PersistentAgentStreamEvent value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public PersistentAgentStreamEvent() { + } + + /** + * Creates or finds a PersistentAgentStreamEvent from its string representation. + * + * @param name a name to look for. + * @return the corresponding PersistentAgentStreamEvent. + */ + @Generated + public static PersistentAgentStreamEvent fromString(String name) { + return fromString(name, PersistentAgentStreamEvent.class); + } + + /** + * Gets known PersistentAgentStreamEvent values. + * + * @return known PersistentAgentStreamEvent values. + */ + @Generated + public static Collection values() { + return values(PersistentAgentStreamEvent.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentThread.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentThread.java new file mode 100644 index 000000000000..fbe6c4a873c6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentThread.java @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.Map; + +/** + * Information about a single thread associated with an agent. + */ +@Immutable +public final class PersistentAgentThread implements JsonSerializable { + + /* + * The identifier, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The object type, which is always 'thread'. + */ + @Generated + private final String object = "thread"; + + /* + * The Unix timestamp, in seconds, representing when this object was created. + */ + @Generated + private final long createdAt; + + /* + * A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + * type + * of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires a list + * of vector store IDs. + */ + @Generated + private final ToolResources toolResources; + + /* + * 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. + */ + @Generated + private final Map metadata; + + /** + * Creates an instance of PersistentAgentThread class. + * + * @param id the id value to set. + * @param createdAt the createdAt value to set. + * @param toolResources the toolResources value to set. + * @param metadata the metadata value to set. + */ + @Generated + private PersistentAgentThread(String id, OffsetDateTime createdAt, ToolResources toolResources, + Map metadata) { + this.id = id; + if (createdAt == null) { + this.createdAt = 0L; + } else { + this.createdAt = createdAt.toEpochSecond(); + } + this.toolResources = toolResources; + this.metadata = metadata; + } + + /** + * Get the id property: The identifier, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the object property: The object type, which is always 'thread'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the createdAt property: The Unix timestamp, in seconds, representing when this object was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC); + } + + /** + * Get the toolResources property: A set of resources that are made available to the agent's tools in this thread. + * The resources are specific to the type + * of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires a list + * of vector store IDs. + * + * @return the toolResources value. + */ + @Generated + public ToolResources getToolResources() { + return this.toolResources; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeLongField("created_at", this.createdAt); + jsonWriter.writeJsonField("tool_resources", this.toolResources); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersistentAgentThread from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersistentAgentThread if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PersistentAgentThread. + */ + @Generated + public static PersistentAgentThread fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OffsetDateTime createdAt = null; + ToolResources toolResources = null; + Map metadata = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("created_at".equals(fieldName)) { + createdAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader.getLong()), ZoneOffset.UTC); + } else if ("tool_resources".equals(fieldName)) { + toolResources = ToolResources.fromJson(reader); + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new PersistentAgentThread(id, createdAt, toolResources, metadata); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentThreadCreationOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentThreadCreationOptions.java new file mode 100644 index 000000000000..5dff0d6cdc9e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentThreadCreationOptions.java @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The details used to create a new agent thread. + */ +@Fluent +public final class PersistentAgentThreadCreationOptions + implements JsonSerializable { + + /* + * The initial messages to associate with the new thread. + */ + @Generated + private List messages; + + /* + * A set of resources that are made available to the agent's tools in this thread. The resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + */ + @Generated + private ToolResources toolResources; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of PersistentAgentThreadCreationOptions class. + */ + @Generated + public PersistentAgentThreadCreationOptions() { + } + + /** + * Get the messages property: The initial messages to associate with the new thread. + * + * @return the messages value. + */ + @Generated + public List getMessages() { + return this.messages; + } + + /** + * Set the messages property: The initial messages to associate with the new thread. + * + * @param messages the messages value to set. + * @return the PersistentAgentThreadCreationOptions object itself. + */ + @Generated + public PersistentAgentThreadCreationOptions setMessages(List messages) { + this.messages = messages; + return this; + } + + /** + * Get the toolResources property: A set of resources that are made available to the agent's tools in this thread. + * The resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + * + * @return the toolResources value. + */ + @Generated + public ToolResources getToolResources() { + return this.toolResources; + } + + /** + * Set the toolResources property: A set of resources that are made available to the agent's tools in this thread. + * The resources are specific to the + * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool + * requires + * a list of vector store IDs. + * + * @param toolResources the toolResources value to set. + * @return the PersistentAgentThreadCreationOptions object itself. + */ + @Generated + public PersistentAgentThreadCreationOptions setToolResources(ToolResources toolResources) { + this.toolResources = toolResources; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the PersistentAgentThreadCreationOptions object itself. + */ + @Generated + public PersistentAgentThreadCreationOptions setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("messages", this.messages, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("tool_resources", this.toolResources); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersistentAgentThreadCreationOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersistentAgentThreadCreationOptions if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the PersistentAgentThreadCreationOptions. + */ + @Generated + public static PersistentAgentThreadCreationOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersistentAgentThreadCreationOptions deserializedPersistentAgentThreadCreationOptions + = new PersistentAgentThreadCreationOptions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("messages".equals(fieldName)) { + List messages + = reader.readArray(reader1 -> ThreadMessageOptions.fromJson(reader1)); + deserializedPersistentAgentThreadCreationOptions.messages = messages; + } else if ("tool_resources".equals(fieldName)) { + deserializedPersistentAgentThreadCreationOptions.toolResources = ToolResources.fromJson(reader); + } else if ("metadata".equals(fieldName)) { + Map metadata = reader.readMap(reader1 -> reader1.getString()); + deserializedPersistentAgentThreadCreationOptions.metadata = metadata; + } else { + reader.skipChildren(); + } + } + return deserializedPersistentAgentThreadCreationOptions; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoice.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoice.java new file mode 100644 index 000000000000..214cc1e323a0 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoice.java @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Specifies a tool the model should use. Use to force the model to call a specific tool. + */ +@Fluent +public final class PersistentAgentsNamedToolChoice implements JsonSerializable { + + /* + * the type of tool. If type is `function`, the function name must be set. + */ + @Generated + private final PersistentAgentsNamedToolChoiceType type; + + /* + * The name of the function to call + */ + @Generated + private FunctionName function; + + /** + * Creates an instance of PersistentAgentsNamedToolChoice class. + * + * @param type the type value to set. + */ + @Generated + public PersistentAgentsNamedToolChoice(PersistentAgentsNamedToolChoiceType type) { + this.type = type; + } + + /** + * Get the type property: the type of tool. If type is `function`, the function name must be set. + * + * @return the type value. + */ + @Generated + public PersistentAgentsNamedToolChoiceType getType() { + return this.type; + } + + /** + * Get the function property: The name of the function to call. + * + * @return the function value. + */ + @Generated + public FunctionName getFunction() { + return this.function; + } + + /** + * Set the function property: The name of the function to call. + * + * @param function the function value to set. + * @return the PersistentAgentsNamedToolChoice object itself. + */ + @Generated + public PersistentAgentsNamedToolChoice setFunction(FunctionName function) { + this.function = function; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeJsonField("function", this.function); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersistentAgentsNamedToolChoice from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersistentAgentsNamedToolChoice if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PersistentAgentsNamedToolChoice. + */ + @Generated + public static PersistentAgentsNamedToolChoice fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersistentAgentsNamedToolChoiceType type = null; + FunctionName function = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + type = PersistentAgentsNamedToolChoiceType.fromString(reader.getString()); + } else if ("function".equals(fieldName)) { + function = FunctionName.fromJson(reader); + } else { + reader.skipChildren(); + } + } + PersistentAgentsNamedToolChoice deserializedPersistentAgentsNamedToolChoice + = new PersistentAgentsNamedToolChoice(type); + deserializedPersistentAgentsNamedToolChoice.function = function; + return deserializedPersistentAgentsNamedToolChoice; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoiceType.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoiceType.java new file mode 100644 index 000000000000..765d3ee4f8f0 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoiceType.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Available tool types for agents named tools. + */ +public final class PersistentAgentsNamedToolChoiceType + extends ExpandableStringEnum { + + /** + * Tool type `function`. + */ + @Generated + public static final PersistentAgentsNamedToolChoiceType FUNCTION = fromString("function"); + + /** + * Tool type `code_interpreter`. + */ + @Generated + public static final PersistentAgentsNamedToolChoiceType CODE_INTERPRETER = fromString("code_interpreter"); + + /** + * Tool type `file_search`. + */ + @Generated + public static final PersistentAgentsNamedToolChoiceType FILE_SEARCH = fromString("file_search"); + + /** + * Tool type `bing_grounding`. + */ + @Generated + public static final PersistentAgentsNamedToolChoiceType BING_GROUNDING = fromString("bing_grounding"); + + /** + * Tool type `fabric_dataagent`. + */ + @Generated + public static final PersistentAgentsNamedToolChoiceType MICROSOFT_FABRIC = fromString("fabric_dataagent"); + + /** + * Tool type `sharepoint_grounding`. + */ + @Generated + public static final PersistentAgentsNamedToolChoiceType SHAREPOINT = fromString("sharepoint_grounding"); + + /** + * Tool type `azure_ai_search`. + */ + @Generated + public static final PersistentAgentsNamedToolChoiceType AZURE_AISEARCH = fromString("azure_ai_search"); + + /** + * Tool type `bing_custom_search`. + */ + @Generated + public static final PersistentAgentsNamedToolChoiceType BING_CUSTOM_SEARCH = fromString("bing_custom_search"); + + /** + * Tool type `connected_agent`. + */ + @Generated + public static final PersistentAgentsNamedToolChoiceType CONNECTED_AGENT = fromString("connected_agent"); + + /** + * Creates a new instance of PersistentAgentsNamedToolChoiceType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public PersistentAgentsNamedToolChoiceType() { + } + + /** + * Creates or finds a PersistentAgentsNamedToolChoiceType from its string representation. + * + * @param name a name to look for. + * @return the corresponding PersistentAgentsNamedToolChoiceType. + */ + @Generated + public static PersistentAgentsNamedToolChoiceType fromString(String name) { + return fromString(name, PersistentAgentsNamedToolChoiceType.class); + } + + /** + * Gets known PersistentAgentsNamedToolChoiceType values. + * + * @return known PersistentAgentsNamedToolChoiceType values. + */ + @Generated + public static Collection values() { + return values(PersistentAgentsNamedToolChoiceType.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormat.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormat.java new file mode 100644 index 000000000000..91712bb3d879 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormat.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to + * be passed to the Run. + * If `text` the model can return text or any value needed. + */ +@Fluent +public final class PersistentAgentsResponseFormat implements JsonSerializable { + + /* + * Must be one of `text` or `json_object`. + */ + @Generated + private ResponseFormat type; + + /** + * Creates an instance of PersistentAgentsResponseFormat class. + */ + @Generated + public PersistentAgentsResponseFormat() { + } + + /** + * Get the type property: Must be one of `text` or `json_object`. + * + * @return the type value. + */ + @Generated + public ResponseFormat getType() { + return this.type; + } + + /** + * Set the type property: Must be one of `text` or `json_object`. + * + * @param type the type value to set. + * @return the PersistentAgentsResponseFormat object itself. + */ + @Generated + public PersistentAgentsResponseFormat setType(ResponseFormat type) { + this.type = type; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PersistentAgentsResponseFormat from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PersistentAgentsResponseFormat if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the PersistentAgentsResponseFormat. + */ + @Generated + public static PersistentAgentsResponseFormat fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PersistentAgentsResponseFormat deserializedPersistentAgentsResponseFormat + = new PersistentAgentsResponseFormat(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedPersistentAgentsResponseFormat.type = ResponseFormat.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedPersistentAgentsResponseFormat; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormatMode.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormatMode.java new file mode 100644 index 000000000000..57135b1637cf --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormatMode.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Represents the mode in which the model will handle the return format of a tool call. + */ +public final class PersistentAgentsResponseFormatMode extends ExpandableStringEnum { + + /** + * Default value. Let the model handle the return format. + */ + @Generated + public static final PersistentAgentsResponseFormatMode AUTO = fromString("auto"); + + /** + * Setting the value to `none`, will result in a 400 Bad request. + */ + @Generated + public static final PersistentAgentsResponseFormatMode NONE = fromString("none"); + + /** + * Creates a new instance of PersistentAgentsResponseFormatMode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public PersistentAgentsResponseFormatMode() { + } + + /** + * Creates or finds a PersistentAgentsResponseFormatMode from its string representation. + * + * @param name a name to look for. + * @return the corresponding PersistentAgentsResponseFormatMode. + */ + @Generated + public static PersistentAgentsResponseFormatMode fromString(String name) { + return fromString(name, PersistentAgentsResponseFormatMode.class); + } + + /** + * Gets known PersistentAgentsResponseFormatMode values. + * + * @return known PersistentAgentsResponseFormatMode values. + */ + @Generated + public static Collection values() { + return values(PersistentAgentsResponseFormatMode.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsToolChoiceOptionMode.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsToolChoiceOptionMode.java new file mode 100644 index 000000000000..d9cd12b801ef --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsToolChoiceOptionMode.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies how the tool choice will be used. + */ +public final class PersistentAgentsToolChoiceOptionMode + extends ExpandableStringEnum { + + /** + * The model will not call a function and instead generates a message. + */ + @Generated + public static final PersistentAgentsToolChoiceOptionMode NONE = fromString("none"); + + /** + * The model can pick between generating a message or calling a function. + */ + @Generated + public static final PersistentAgentsToolChoiceOptionMode AUTO = fromString("auto"); + + /** + * Creates a new instance of PersistentAgentsToolChoiceOptionMode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public PersistentAgentsToolChoiceOptionMode() { + } + + /** + * Creates or finds a PersistentAgentsToolChoiceOptionMode from its string representation. + * + * @param name a name to look for. + * @return the corresponding PersistentAgentsToolChoiceOptionMode. + */ + @Generated + public static PersistentAgentsToolChoiceOptionMode fromString(String name) { + return fromString(name, PersistentAgentsToolChoiceOptionMode.class); + } + + /** + * Gets known PersistentAgentsToolChoiceOptionMode values. + * + * @return known PersistentAgentsToolChoiceOptionMode values. + */ + @Generated + public static Collection values() { + return values(PersistentAgentsToolChoiceOptionMode.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredAction.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredAction.java new file mode 100644 index 000000000000..997381df7771 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredAction.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An abstract representation of a required action for an agent thread run to continue. + */ +@Immutable +public class RequiredAction implements JsonSerializable { + + /* + * The object type. + */ + @Generated + private String type = "RequiredAction"; + + /** + * Creates an instance of RequiredAction class. + */ + @Generated + protected RequiredAction() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RequiredAction from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RequiredAction if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the RequiredAction. + */ + @Generated + public static RequiredAction fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("submit_tool_outputs".equals(discriminatorValue)) { + return SubmitToolOutputsAction.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static RequiredAction fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RequiredAction deserializedRequiredAction = new RequiredAction(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedRequiredAction.type = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedRequiredAction; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredFunctionToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredFunctionToolCall.java new file mode 100644 index 000000000000..ab7da839153a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredFunctionToolCall.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A representation of a requested call to a function tool, needed by the model to continue evaluation of a run. + */ +@Immutable +public final class RequiredFunctionToolCall extends RequiredToolCall { + + /* + * The object type for the required tool call. + */ + @Generated + private String type = "function"; + + /* + * Detailed information about the function to be executed by the tool that includes name and arguments. + */ + @Generated + private final RequiredFunctionToolCallDetails function; + + /** + * Creates an instance of RequiredFunctionToolCall class. + * + * @param id the id value to set. + * @param function the function value to set. + */ + @Generated + private RequiredFunctionToolCall(String id, RequiredFunctionToolCallDetails function) { + super(id); + this.function = function; + } + + /** + * Get the type property: The object type for the required tool call. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the function property: Detailed information about the function to be executed by the tool that includes name + * and arguments. + * + * @return the function value. + */ + @Generated + public RequiredFunctionToolCallDetails getFunction() { + return this.function; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeJsonField("function", this.function); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RequiredFunctionToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RequiredFunctionToolCall if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RequiredFunctionToolCall. + */ + @Generated + public static RequiredFunctionToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + RequiredFunctionToolCallDetails function = null; + String type = "function"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("function".equals(fieldName)) { + function = RequiredFunctionToolCallDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RequiredFunctionToolCall deserializedRequiredFunctionToolCall = new RequiredFunctionToolCall(id, function); + deserializedRequiredFunctionToolCall.type = type; + return deserializedRequiredFunctionToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredFunctionToolCallDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredFunctionToolCallDetails.java new file mode 100644 index 000000000000..3dc92215391c --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredFunctionToolCallDetails.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * 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. + */ +@Immutable +public final class RequiredFunctionToolCallDetails implements JsonSerializable { + + /* + * The name of the function. + */ + @Generated + private final String name; + + /* + * 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. + */ + @Generated + private final String arguments; + + /** + * Creates an instance of RequiredFunctionToolCallDetails class. + * + * @param name the name value to set. + * @param arguments the arguments value to set. + */ + @Generated + private RequiredFunctionToolCallDetails(String name, String arguments) { + this.name = name; + this.arguments = arguments; + } + + /** + * Get the name property: The name of the function. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the arguments property: 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. + * + * @return the arguments value. + */ + @Generated + public String getArguments() { + return this.arguments; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("arguments", this.arguments); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RequiredFunctionToolCallDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RequiredFunctionToolCallDetails if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RequiredFunctionToolCallDetails. + */ + @Generated + public static RequiredFunctionToolCallDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String arguments = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("arguments".equals(fieldName)) { + arguments = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new RequiredFunctionToolCallDetails(name, arguments); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredToolCall.java new file mode 100644 index 000000000000..47a274d386c7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RequiredToolCall.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An abstract representation of a tool invocation needed by the model to continue a run. + */ +@Immutable +public class RequiredToolCall implements JsonSerializable { + + /* + * The object type for the required tool call. + */ + @Generated + private String type = "RequiredToolCall"; + + /* + * The ID of the tool call. This ID must be referenced when submitting tool outputs. + */ + @Generated + private final String id; + + /** + * Creates an instance of RequiredToolCall class. + * + * @param id the id value to set. + */ + @Generated + protected RequiredToolCall(String id) { + this.id = id; + } + + /** + * Get the type property: The object type for the required tool call. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the id property: The ID of the tool call. This ID must be referenced when submitting tool outputs. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RequiredToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RequiredToolCall if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RequiredToolCall. + */ + @Generated + public static RequiredToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("function".equals(discriminatorValue)) { + return RequiredFunctionToolCall.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static RequiredToolCall fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RequiredToolCall deserializedRequiredToolCall = new RequiredToolCall(id); + deserializedRequiredToolCall.type = type; + return deserializedRequiredToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormat.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormat.java new file mode 100644 index 000000000000..2c4f851f81e6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormat.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Possible API response formats. + */ +public final class ResponseFormat extends ExpandableStringEnum { + + /** + * `text` format should be used for requests involving any sort of ToolCall. + */ + @Generated + public static final ResponseFormat TEXT = fromString("text"); + + /** + * Using `json_object` format will limit the usage of ToolCall to only functions. + */ + @Generated + public static final ResponseFormat JSON_OBJECT = fromString("json_object"); + + /** + * Creates a new instance of ResponseFormat value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ResponseFormat() { + } + + /** + * Creates or finds a ResponseFormat from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResponseFormat. + */ + @Generated + public static ResponseFormat fromString(String name) { + return fromString(name, ResponseFormat.class); + } + + /** + * Gets known ResponseFormat values. + * + * @return known ResponseFormat values. + */ + @Generated + public static Collection values() { + return values(ResponseFormat.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormatJsonSchema.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormatJsonSchema.java new file mode 100644 index 000000000000..fc38bf73dba5 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormatJsonSchema.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A description of what the response format is for, used by the model to determine how to respond in the format. + */ +@Fluent +public final class ResponseFormatJsonSchema implements JsonSerializable { + + /* + * A description of what the response format is for, used by the model to determine how to respond in the format. + */ + @Generated + private String description; + + /* + * The name of a schema. + */ + @Generated + private final String name; + + /* + * The JSON schema object, describing the response format. + */ + @Generated + private final BinaryData schema; + + /** + * Creates an instance of ResponseFormatJsonSchema class. + * + * @param name the name value to set. + * @param schema the schema value to set. + */ + @Generated + public ResponseFormatJsonSchema(String name, BinaryData schema) { + this.name = name; + this.schema = schema; + } + + /** + * Get the description property: A description of what the response format is for, used by the model to determine + * how to respond in the format. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: A description of what the response format is for, used by the model to determine + * how to respond in the format. + * + * @param description the description value to set. + * @return the ResponseFormatJsonSchema object itself. + */ + @Generated + public ResponseFormatJsonSchema setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the name property: The name of a schema. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the schema property: The JSON schema object, describing the response format. + * + * @return the schema value. + */ + @Generated + public BinaryData getSchema() { + return this.schema; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeFieldName("schema"); + this.schema.writeTo(jsonWriter); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResponseFormatJsonSchema from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResponseFormatJsonSchema if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResponseFormatJsonSchema. + */ + @Generated + public static ResponseFormatJsonSchema fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + BinaryData schema = null; + String description = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("schema".equals(fieldName)) { + schema = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else { + reader.skipChildren(); + } + } + ResponseFormatJsonSchema deserializedResponseFormatJsonSchema = new ResponseFormatJsonSchema(name, schema); + deserializedResponseFormatJsonSchema.description = description; + return deserializedResponseFormatJsonSchema; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormatJsonSchemaType.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormatJsonSchemaType.java new file mode 100644 index 000000000000..efcf2e1a4171 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ResponseFormatJsonSchemaType.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The type of response format being defined: `json_schema`. + */ +@Immutable +public final class ResponseFormatJsonSchemaType implements JsonSerializable { + + /* + * Type + */ + @Generated + private final String type = "json_schema"; + + /* + * The JSON schema, describing response format. + */ + @Generated + private final ResponseFormatJsonSchema jsonSchema; + + /** + * Creates an instance of ResponseFormatJsonSchemaType class. + * + * @param jsonSchema the jsonSchema value to set. + */ + @Generated + public ResponseFormatJsonSchemaType(ResponseFormatJsonSchema jsonSchema) { + this.jsonSchema = jsonSchema; + } + + /** + * Get the type property: Type. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the jsonSchema property: The JSON schema, describing response format. + * + * @return the jsonSchema value. + */ + @Generated + public ResponseFormatJsonSchema getJsonSchema() { + return this.jsonSchema; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("json_schema", this.jsonSchema); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResponseFormatJsonSchemaType from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResponseFormatJsonSchemaType if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ResponseFormatJsonSchemaType. + */ + @Generated + public static ResponseFormatJsonSchemaType fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResponseFormatJsonSchema jsonSchema = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("json_schema".equals(fieldName)) { + jsonSchema = ResponseFormatJsonSchema.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new ResponseFormatJsonSchemaType(jsonSchema); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunAdditionalFieldList.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunAdditionalFieldList.java new file mode 100644 index 000000000000..e2f28e48cdb5 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunAdditionalFieldList.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * A list of additional fields to include in the response. + */ +public final class RunAdditionalFieldList extends ExpandableStringEnum { + + /** + * File search result content. + */ + @Generated + public static final RunAdditionalFieldList FILE_SEARCH_CONTENTS + = fromString("step_details.tool_calls[*].file_search.results[*].content"); + + /** + * Creates a new instance of RunAdditionalFieldList value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public RunAdditionalFieldList() { + } + + /** + * Creates or finds a RunAdditionalFieldList from its string representation. + * + * @param name a name to look for. + * @return the corresponding RunAdditionalFieldList. + */ + @Generated + public static RunAdditionalFieldList fromString(String name) { + return fromString(name, RunAdditionalFieldList.class); + } + + /** + * Gets known RunAdditionalFieldList values. + * + * @return known RunAdditionalFieldList values. + */ + @Generated + public static Collection values() { + return values(RunAdditionalFieldList.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunCompletionUsage.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunCompletionUsage.java new file mode 100644 index 000000000000..961a85d98c01 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunCompletionUsage.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. + * `in_progress`, `queued`, etc.). + */ +@Immutable +public final class RunCompletionUsage implements JsonSerializable { + + /* + * Number of completion tokens used over the course of the run. + */ + @Generated + private final long completionTokens; + + /* + * Number of prompt tokens used over the course of the run. + */ + @Generated + private final long promptTokens; + + /* + * Total number of tokens used (prompt + completion). + */ + @Generated + private final long totalTokens; + + /** + * Creates an instance of RunCompletionUsage class. + * + * @param completionTokens the completionTokens value to set. + * @param promptTokens the promptTokens value to set. + * @param totalTokens the totalTokens value to set. + */ + @Generated + private RunCompletionUsage(long completionTokens, long promptTokens, long totalTokens) { + this.completionTokens = completionTokens; + this.promptTokens = promptTokens; + this.totalTokens = totalTokens; + } + + /** + * Get the completionTokens property: Number of completion tokens used over the course of the run. + * + * @return the completionTokens value. + */ + @Generated + public long getCompletionTokens() { + return this.completionTokens; + } + + /** + * Get the promptTokens property: Number of prompt tokens used over the course of the run. + * + * @return the promptTokens value. + */ + @Generated + public long getPromptTokens() { + return this.promptTokens; + } + + /** + * Get the totalTokens property: Total number of tokens used (prompt + completion). + * + * @return the totalTokens value. + */ + @Generated + public long getTotalTokens() { + return this.totalTokens; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeLongField("completion_tokens", this.completionTokens); + jsonWriter.writeLongField("prompt_tokens", this.promptTokens); + jsonWriter.writeLongField("total_tokens", this.totalTokens); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunCompletionUsage from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunCompletionUsage if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunCompletionUsage. + */ + @Generated + public static RunCompletionUsage fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + long completionTokens = 0L; + long promptTokens = 0L; + long totalTokens = 0L; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("completion_tokens".equals(fieldName)) { + completionTokens = reader.getLong(); + } else if ("prompt_tokens".equals(fieldName)) { + promptTokens = reader.getLong(); + } else if ("total_tokens".equals(fieldName)) { + totalTokens = reader.getLong(); + } else { + reader.skipChildren(); + } + } + return new RunCompletionUsage(completionTokens, promptTokens, totalTokens); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunError.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunError.java new file mode 100644 index 000000000000..abbabd80172f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunError.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The details of an error as encountered by an agent thread run. + */ +@Immutable +public final class RunError implements JsonSerializable { + + /* + * The status for the error. + */ + @Generated + private final String code; + + /* + * The human-readable text associated with the error. + */ + @Generated + private final String message; + + /** + * Creates an instance of RunError class. + * + * @param code the code value to set. + * @param message the message value to set. + */ + @Generated + private RunError(String code, String message) { + this.code = code; + this.message = message; + } + + /** + * Get the code property: The status for the error. + * + * @return the code value. + */ + @Generated + public String getCode() { + return this.code; + } + + /** + * Get the message property: The human-readable text associated with the error. + * + * @return the message value. + */ + @Generated + public String getMessage() { + return this.message; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("code", this.code); + jsonWriter.writeStringField("message", this.message); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunError if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunError. + */ + @Generated + public static RunError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String code = null; + String message = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("code".equals(fieldName)) { + code = reader.getString(); + } else if ("message".equals(fieldName)) { + message = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new RunError(code, message); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStatus.java new file mode 100644 index 000000000000..a448b0a534ae --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStatus.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Possible values for the status of an agent thread run. + */ +public final class RunStatus extends ExpandableStringEnum { + + /** + * Represents a run that is queued to start. + */ + @Generated + public static final RunStatus QUEUED = fromString("queued"); + + /** + * Represents a run that is in progress. + */ + @Generated + public static final RunStatus IN_PROGRESS = fromString("in_progress"); + + /** + * Represents a run that needs another operation, such as tool output submission, to continue. + */ + @Generated + public static final RunStatus REQUIRES_ACTION = fromString("requires_action"); + + /** + * Represents a run that is in the process of cancellation. + */ + @Generated + public static final RunStatus CANCELLING = fromString("cancelling"); + + /** + * Represents a run that has been cancelled. + */ + @Generated + public static final RunStatus CANCELLED = fromString("cancelled"); + + /** + * Represents a run that failed. + */ + @Generated + public static final RunStatus FAILED = fromString("failed"); + + /** + * Represents a run that successfully completed. + */ + @Generated + public static final RunStatus COMPLETED = fromString("completed"); + + /** + * Represents a run that expired before it could otherwise finish. + */ + @Generated + public static final RunStatus EXPIRED = fromString("expired"); + + /** + * Creates a new instance of RunStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public RunStatus() { + } + + /** + * Creates or finds a RunStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding RunStatus. + */ + @Generated + public static RunStatus fromString(String name) { + return fromString(name, RunStatus.class); + } + + /** + * Gets known RunStatus values. + * + * @return known RunStatus values. + */ + @Generated + public static Collection values() { + return values(RunStatus.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStep.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStep.java new file mode 100644 index 000000000000..e9c5932d3fb9 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStep.java @@ -0,0 +1,466 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.Map; + +/** + * Detailed information about a single step of an agent thread run. + */ +@Immutable +public final class RunStep implements JsonSerializable { + + /* + * The identifier, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The object type, which is always 'thread.run.step'. + */ + @Generated + private final String object = "thread.run.step"; + + /* + * The type of run step, which can be either message_creation or tool_calls. + */ + @Generated + private final RunStepType type; + + /* + * The ID of the agent associated with the run step. + */ + @Generated + private final String assistantId; + + /* + * The ID of the thread that was run. + */ + @Generated + private final String threadId; + + /* + * The ID of the run that this run step is a part of. + */ + @Generated + private final String runId; + + /* + * The status of this run step. + */ + @Generated + private final RunStepStatus status; + + /* + * The details for this run step. + */ + @Generated + private final RunStepDetails stepDetails; + + /* + * If applicable, information about the last error encountered by this run step. + */ + @Generated + private final RunStepError lastError; + + /* + * The Unix timestamp, in seconds, representing when this object was created. + */ + @Generated + private final long createdAt; + + /* + * The Unix timestamp, in seconds, representing when this item expired. + */ + @Generated + private final Long expiredAt; + + /* + * The Unix timestamp, in seconds, representing when this completed. + */ + @Generated + private final Long completedAt; + + /* + * The Unix timestamp, in seconds, representing when this was cancelled. + */ + @Generated + private final Long cancelledAt; + + /* + * The Unix timestamp, in seconds, representing when this failed. + */ + @Generated + private final Long failedAt; + + /* + * Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + */ + @Generated + private RunStepCompletionUsage usage; + + /* + * 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. + */ + @Generated + private final Map metadata; + + /** + * Creates an instance of RunStep class. + * + * @param id the id value to set. + * @param type the type value to set. + * @param assistantId the assistantId value to set. + * @param threadId the threadId value to set. + * @param runId the runId value to set. + * @param status the status value to set. + * @param stepDetails the stepDetails value to set. + * @param lastError the lastError value to set. + * @param createdAt the createdAt value to set. + * @param expiredAt the expiredAt value to set. + * @param completedAt the completedAt value to set. + * @param cancelledAt the cancelledAt value to set. + * @param failedAt the failedAt value to set. + * @param metadata the metadata value to set. + */ + @Generated + private RunStep(String id, RunStepType type, String assistantId, String threadId, String runId, + RunStepStatus status, RunStepDetails stepDetails, RunStepError lastError, OffsetDateTime createdAt, + OffsetDateTime expiredAt, OffsetDateTime completedAt, OffsetDateTime cancelledAt, OffsetDateTime failedAt, + Map metadata) { + this.id = id; + this.type = type; + this.assistantId = assistantId; + this.threadId = threadId; + this.runId = runId; + this.status = status; + this.stepDetails = stepDetails; + this.lastError = lastError; + if (createdAt == null) { + this.createdAt = 0L; + } else { + this.createdAt = createdAt.toEpochSecond(); + } + if (expiredAt == null) { + this.expiredAt = null; + } else { + this.expiredAt = expiredAt.toEpochSecond(); + } + if (completedAt == null) { + this.completedAt = null; + } else { + this.completedAt = completedAt.toEpochSecond(); + } + if (cancelledAt == null) { + this.cancelledAt = null; + } else { + this.cancelledAt = cancelledAt.toEpochSecond(); + } + if (failedAt == null) { + this.failedAt = null; + } else { + this.failedAt = failedAt.toEpochSecond(); + } + this.metadata = metadata; + } + + /** + * Get the id property: The identifier, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the object property: The object type, which is always 'thread.run.step'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the type property: The type of run step, which can be either message_creation or tool_calls. + * + * @return the type value. + */ + @Generated + public RunStepType getType() { + return this.type; + } + + /** + * Get the assistantId property: The ID of the agent associated with the run step. + * + * @return the assistantId value. + */ + @Generated + public String getAssistantId() { + return this.assistantId; + } + + /** + * Get the threadId property: The ID of the thread that was run. + * + * @return the threadId value. + */ + @Generated + public String getThreadId() { + return this.threadId; + } + + /** + * Get the runId property: The ID of the run that this run step is a part of. + * + * @return the runId value. + */ + @Generated + public String getRunId() { + return this.runId; + } + + /** + * Get the status property: The status of this run step. + * + * @return the status value. + */ + @Generated + public RunStepStatus getStatus() { + return this.status; + } + + /** + * Get the stepDetails property: The details for this run step. + * + * @return the stepDetails value. + */ + @Generated + public RunStepDetails getStepDetails() { + return this.stepDetails; + } + + /** + * Get the lastError property: If applicable, information about the last error encountered by this run step. + * + * @return the lastError value. + */ + @Generated + public RunStepError getLastError() { + return this.lastError; + } + + /** + * Get the createdAt property: The Unix timestamp, in seconds, representing when this object was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC); + } + + /** + * Get the expiredAt property: The Unix timestamp, in seconds, representing when this item expired. + * + * @return the expiredAt value. + */ + @Generated + public OffsetDateTime getExpiredAt() { + if (this.expiredAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.expiredAt), ZoneOffset.UTC); + } + + /** + * Get the completedAt property: The Unix timestamp, in seconds, representing when this completed. + * + * @return the completedAt value. + */ + @Generated + public OffsetDateTime getCompletedAt() { + if (this.completedAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.completedAt), ZoneOffset.UTC); + } + + /** + * Get the cancelledAt property: The Unix timestamp, in seconds, representing when this was cancelled. + * + * @return the cancelledAt value. + */ + @Generated + public OffsetDateTime getCancelledAt() { + if (this.cancelledAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.cancelledAt), ZoneOffset.UTC); + } + + /** + * Get the failedAt property: The Unix timestamp, in seconds, representing when this failed. + * + * @return the failedAt value. + */ + @Generated + public OffsetDateTime getFailedAt() { + if (this.failedAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.failedAt), ZoneOffset.UTC); + } + + /** + * Get the usage property: Usage statistics related to the run step. This value will be `null` while the run step's + * status is `in_progress`. + * + * @return the usage value. + */ + @Generated + public RunStepCompletionUsage getUsage() { + return this.usage; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeStringField("assistant_id", this.assistantId); + jsonWriter.writeStringField("thread_id", this.threadId); + jsonWriter.writeStringField("run_id", this.runId); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("step_details", this.stepDetails); + jsonWriter.writeJsonField("last_error", this.lastError); + jsonWriter.writeLongField("created_at", this.createdAt); + jsonWriter.writeNumberField("expired_at", this.expiredAt); + jsonWriter.writeNumberField("completed_at", this.completedAt); + jsonWriter.writeNumberField("cancelled_at", this.cancelledAt); + jsonWriter.writeNumberField("failed_at", this.failedAt); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("usage", this.usage); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStep from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStep if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStep. + */ + @Generated + public static RunStep fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + RunStepType type = null; + String assistantId = null; + String threadId = null; + String runId = null; + RunStepStatus status = null; + RunStepDetails stepDetails = null; + RunStepError lastError = null; + OffsetDateTime createdAt = null; + OffsetDateTime expiredAt = null; + OffsetDateTime completedAt = null; + OffsetDateTime cancelledAt = null; + OffsetDateTime failedAt = null; + Map metadata = null; + RunStepCompletionUsage usage = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("type".equals(fieldName)) { + type = RunStepType.fromString(reader.getString()); + } else if ("assistant_id".equals(fieldName)) { + assistantId = reader.getString(); + } else if ("thread_id".equals(fieldName)) { + threadId = reader.getString(); + } else if ("run_id".equals(fieldName)) { + runId = reader.getString(); + } else if ("status".equals(fieldName)) { + status = RunStepStatus.fromString(reader.getString()); + } else if ("step_details".equals(fieldName)) { + stepDetails = RunStepDetails.fromJson(reader); + } else if ("last_error".equals(fieldName)) { + lastError = RunStepError.fromJson(reader); + } else if ("created_at".equals(fieldName)) { + createdAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader.getLong()), ZoneOffset.UTC); + } else if ("expired_at".equals(fieldName)) { + Long expiredAtHolder = reader.getNullable(JsonReader::getLong); + if (expiredAtHolder != null) { + expiredAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(expiredAtHolder), ZoneOffset.UTC); + } + } else if ("completed_at".equals(fieldName)) { + Long completedAtHolder = reader.getNullable(JsonReader::getLong); + if (completedAtHolder != null) { + completedAt + = OffsetDateTime.ofInstant(Instant.ofEpochSecond(completedAtHolder), ZoneOffset.UTC); + } + } else if ("cancelled_at".equals(fieldName)) { + Long cancelledAtHolder = reader.getNullable(JsonReader::getLong); + if (cancelledAtHolder != null) { + cancelledAt + = OffsetDateTime.ofInstant(Instant.ofEpochSecond(cancelledAtHolder), ZoneOffset.UTC); + } + } else if ("failed_at".equals(fieldName)) { + Long failedAtHolder = reader.getNullable(JsonReader::getLong); + if (failedAtHolder != null) { + failedAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(failedAtHolder), ZoneOffset.UTC); + } + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else if ("usage".equals(fieldName)) { + usage = RunStepCompletionUsage.fromJson(reader); + } else { + reader.skipChildren(); + } + } + RunStep deserializedRunStep = new RunStep(id, type, assistantId, threadId, runId, status, stepDetails, + lastError, createdAt, expiredAt, completedAt, cancelledAt, failedAt, metadata); + deserializedRunStep.usage = usage; + return deserializedRunStep; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepAzureAISearchToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepAzureAISearchToolCall.java new file mode 100644 index 000000000000..59d791eb5d19 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepAzureAISearchToolCall.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * A record of a call to an Azure AI Search tool, issued by the model in evaluation of a defined tool, that represents + * executed Azure AI search. + */ +@Immutable +public final class RunStepAzureAISearchToolCall extends RunStepToolCall { + + /* + * The object type. + */ + @Generated + private String type = "azure_ai_search"; + + /* + * Reserved for future use. + */ + @Generated + private final Map azureAISearch; + + /** + * Creates an instance of RunStepAzureAISearchToolCall class. + * + * @param id the id value to set. + * @param azureAISearch the azureAISearch value to set. + */ + @Generated + private RunStepAzureAISearchToolCall(String id, Map azureAISearch) { + super(id); + this.azureAISearch = azureAISearch; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the azureAISearch property: Reserved for future use. + * + * @return the azureAISearch value. + */ + @Generated + public Map getAzureAISearch() { + return this.azureAISearch; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeMapField("azure_ai_search", this.azureAISearch, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepAzureAISearchToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepAzureAISearchToolCall if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepAzureAISearchToolCall. + */ + @Generated + public static RunStepAzureAISearchToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + Map azureAISearch = null; + String type = "azure_ai_search"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("azure_ai_search".equals(fieldName)) { + azureAISearch = reader.readMap(reader1 -> reader1.getString()); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepAzureAISearchToolCall deserializedRunStepAzureAISearchToolCall + = new RunStepAzureAISearchToolCall(id, azureAISearch); + deserializedRunStepAzureAISearchToolCall.type = type; + return deserializedRunStepAzureAISearchToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingCustomSearchToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingCustomSearchToolCall.java new file mode 100644 index 000000000000..c817f5cef9ee --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingCustomSearchToolCall.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * A record of a call to a bing custom search tool, issued by the model in evaluation of a defined tool, that represents + * executed search with bing custom search. + */ +@Immutable +public final class RunStepBingCustomSearchToolCall extends RunStepToolCall { + + /* + * The object type. + */ + @Generated + private String type = "bing_custom_search"; + + /* + * Reserved for future use. + */ + @Generated + private final Map bingCustomSearch; + + /** + * Creates an instance of RunStepBingCustomSearchToolCall class. + * + * @param id the id value to set. + * @param bingCustomSearch the bingCustomSearch value to set. + */ + @Generated + private RunStepBingCustomSearchToolCall(String id, Map bingCustomSearch) { + super(id); + this.bingCustomSearch = bingCustomSearch; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the bingCustomSearch property: Reserved for future use. + * + * @return the bingCustomSearch value. + */ + @Generated + public Map getBingCustomSearch() { + return this.bingCustomSearch; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeMapField("bing_custom_search", this.bingCustomSearch, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepBingCustomSearchToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepBingCustomSearchToolCall if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepBingCustomSearchToolCall. + */ + @Generated + public static RunStepBingCustomSearchToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + Map bingCustomSearch = null; + String type = "bing_custom_search"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("bing_custom_search".equals(fieldName)) { + bingCustomSearch = reader.readMap(reader1 -> reader1.getString()); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepBingCustomSearchToolCall deserializedRunStepBingCustomSearchToolCall + = new RunStepBingCustomSearchToolCall(id, bingCustomSearch); + deserializedRunStepBingCustomSearchToolCall.type = type; + return deserializedRunStepBingCustomSearchToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingGroundingToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingGroundingToolCall.java new file mode 100644 index 000000000000..6958a86355ac --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingGroundingToolCall.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * A record of a call to a bing grounding tool, issued by the model in evaluation of a defined tool, that represents + * executed search with bing grounding. + */ +@Immutable +public final class RunStepBingGroundingToolCall extends RunStepToolCall { + + /* + * The object type. + */ + @Generated + private String type = "bing_grounding"; + + /* + * Reserved for future use. + */ + @Generated + private final Map bingGrounding; + + /** + * Creates an instance of RunStepBingGroundingToolCall class. + * + * @param id the id value to set. + * @param bingGrounding the bingGrounding value to set. + */ + @Generated + private RunStepBingGroundingToolCall(String id, Map bingGrounding) { + super(id); + this.bingGrounding = bingGrounding; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the bingGrounding property: Reserved for future use. + * + * @return the bingGrounding value. + */ + @Generated + public Map getBingGrounding() { + return this.bingGrounding; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeMapField("bing_grounding", this.bingGrounding, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepBingGroundingToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepBingGroundingToolCall if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepBingGroundingToolCall. + */ + @Generated + public static RunStepBingGroundingToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + Map bingGrounding = null; + String type = "bing_grounding"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("bing_grounding".equals(fieldName)) { + bingGrounding = reader.readMap(reader1 -> reader1.getString()); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepBingGroundingToolCall deserializedRunStepBingGroundingToolCall + = new RunStepBingGroundingToolCall(id, bingGrounding); + deserializedRunStepBingGroundingToolCall.type = type; + return deserializedRunStepBingGroundingToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterImageOutput.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterImageOutput.java new file mode 100644 index 000000000000..15efa67c5afb --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterImageOutput.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A representation of an image output emitted by a code interpreter tool in response to a tool call by the model. + */ +@Immutable +public final class RunStepCodeInterpreterImageOutput extends RunStepCodeInterpreterToolCallOutput { + + /* + * The object type. + */ + @Generated + private String type = "image"; + + /* + * Referential information for the image associated with this output. + */ + @Generated + private final RunStepCodeInterpreterImageReference image; + + /** + * Creates an instance of RunStepCodeInterpreterImageOutput class. + * + * @param image the image value to set. + */ + @Generated + private RunStepCodeInterpreterImageOutput(RunStepCodeInterpreterImageReference image) { + this.image = image; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the image property: Referential information for the image associated with this output. + * + * @return the image value. + */ + @Generated + public RunStepCodeInterpreterImageReference getImage() { + return this.image; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("image", this.image); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepCodeInterpreterImageOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepCodeInterpreterImageOutput if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepCodeInterpreterImageOutput. + */ + @Generated + public static RunStepCodeInterpreterImageOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepCodeInterpreterImageReference image = null; + String type = "image"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("image".equals(fieldName)) { + image = RunStepCodeInterpreterImageReference.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepCodeInterpreterImageOutput deserializedRunStepCodeInterpreterImageOutput + = new RunStepCodeInterpreterImageOutput(image); + deserializedRunStepCodeInterpreterImageOutput.type = type; + return deserializedRunStepCodeInterpreterImageOutput; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterImageReference.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterImageReference.java new file mode 100644 index 000000000000..a3b4a8ad6094 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterImageReference.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An image reference emitted by a code interpreter tool in response to a tool call by the model. + */ +@Immutable +public final class RunStepCodeInterpreterImageReference + implements JsonSerializable { + + /* + * The ID of the file associated with this image. + */ + @Generated + private final String fileId; + + /** + * Creates an instance of RunStepCodeInterpreterImageReference class. + * + * @param fileId the fileId value to set. + */ + @Generated + private RunStepCodeInterpreterImageReference(String fileId) { + this.fileId = fileId; + } + + /** + * Get the fileId property: The ID of the file associated with this image. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepCodeInterpreterImageReference from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepCodeInterpreterImageReference if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepCodeInterpreterImageReference. + */ + @Generated + public static RunStepCodeInterpreterImageReference fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String fileId = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + fileId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new RunStepCodeInterpreterImageReference(fileId); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterLogOutput.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterLogOutput.java new file mode 100644 index 000000000000..2ce56613badf --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterLogOutput.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A representation of a log output emitted by a code interpreter tool in response to a tool call by the model. + */ +@Immutable +public final class RunStepCodeInterpreterLogOutput extends RunStepCodeInterpreterToolCallOutput { + + /* + * The object type. + */ + @Generated + private String type = "logs"; + + /* + * The serialized log output emitted by the code interpreter. + */ + @Generated + private final String logs; + + /** + * Creates an instance of RunStepCodeInterpreterLogOutput class. + * + * @param logs the logs value to set. + */ + @Generated + private RunStepCodeInterpreterLogOutput(String logs) { + this.logs = logs; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the logs property: The serialized log output emitted by the code interpreter. + * + * @return the logs value. + */ + @Generated + public String getLogs() { + return this.logs; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("logs", this.logs); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepCodeInterpreterLogOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepCodeInterpreterLogOutput if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepCodeInterpreterLogOutput. + */ + @Generated + public static RunStepCodeInterpreterLogOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String logs = null; + String type = "logs"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("logs".equals(fieldName)) { + logs = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepCodeInterpreterLogOutput deserializedRunStepCodeInterpreterLogOutput + = new RunStepCodeInterpreterLogOutput(logs); + deserializedRunStepCodeInterpreterLogOutput.type = type; + return deserializedRunStepCodeInterpreterLogOutput; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCall.java new file mode 100644 index 000000000000..cf67448ea566 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCall.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * 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. + */ +@Immutable +public final class RunStepCodeInterpreterToolCall extends RunStepToolCall { + + /* + * The object type. + */ + @Generated + private String type = "code_interpreter"; + + /* + * The details of the tool call to the code interpreter tool. + */ + @Generated + private final RunStepCodeInterpreterToolCallDetails codeInterpreter; + + /** + * Creates an instance of RunStepCodeInterpreterToolCall class. + * + * @param id the id value to set. + * @param codeInterpreter the codeInterpreter value to set. + */ + @Generated + private RunStepCodeInterpreterToolCall(String id, RunStepCodeInterpreterToolCallDetails codeInterpreter) { + super(id); + this.codeInterpreter = codeInterpreter; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the codeInterpreter property: The details of the tool call to the code interpreter tool. + * + * @return the codeInterpreter value. + */ + @Generated + public RunStepCodeInterpreterToolCallDetails getCodeInterpreter() { + return this.codeInterpreter; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeJsonField("code_interpreter", this.codeInterpreter); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepCodeInterpreterToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepCodeInterpreterToolCall if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepCodeInterpreterToolCall. + */ + @Generated + public static RunStepCodeInterpreterToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + RunStepCodeInterpreterToolCallDetails codeInterpreter = null; + String type = "code_interpreter"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("code_interpreter".equals(fieldName)) { + codeInterpreter = RunStepCodeInterpreterToolCallDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepCodeInterpreterToolCall deserializedRunStepCodeInterpreterToolCall + = new RunStepCodeInterpreterToolCall(id, codeInterpreter); + deserializedRunStepCodeInterpreterToolCall.type = type; + return deserializedRunStepCodeInterpreterToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCallDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCallDetails.java new file mode 100644 index 000000000000..9ddaab109c1d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCallDetails.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The detailed information about a code interpreter invocation by the model. + */ +@Immutable +public final class RunStepCodeInterpreterToolCallDetails + implements JsonSerializable { + + /* + * The input provided by the model to the code interpreter tool. + */ + @Generated + private final String input; + + /* + * The outputs produced by the code interpreter tool back to the model in response to the tool call. + */ + @Generated + private final List outputs; + + /** + * Creates an instance of RunStepCodeInterpreterToolCallDetails class. + * + * @param input the input value to set. + * @param outputs the outputs value to set. + */ + @Generated + private RunStepCodeInterpreterToolCallDetails(String input, List outputs) { + this.input = input; + this.outputs = outputs; + } + + /** + * Get the input property: The input provided by the model to the code interpreter tool. + * + * @return the input value. + */ + @Generated + public String getInput() { + return this.input; + } + + /** + * Get the outputs property: The outputs produced by the code interpreter tool back to the model in response to the + * tool call. + * + * @return the outputs value. + */ + @Generated + public List getOutputs() { + return this.outputs; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("input", this.input); + jsonWriter.writeArrayField("outputs", this.outputs, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepCodeInterpreterToolCallDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepCodeInterpreterToolCallDetails if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepCodeInterpreterToolCallDetails. + */ + @Generated + public static RunStepCodeInterpreterToolCallDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String input = null; + List outputs = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("input".equals(fieldName)) { + input = reader.getString(); + } else if ("outputs".equals(fieldName)) { + outputs = reader.readArray(reader1 -> RunStepCodeInterpreterToolCallOutput.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new RunStepCodeInterpreterToolCallDetails(input, outputs); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCallOutput.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCallOutput.java new file mode 100644 index 000000000000..1f82fba54975 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCodeInterpreterToolCallOutput.java @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An abstract representation of an emitted output from a code interpreter tool. + */ +@Immutable +public class RunStepCodeInterpreterToolCallOutput implements JsonSerializable { + + /* + * The object type. + */ + @Generated + private String type = "RunStepCodeInterpreterToolCallOutput"; + + /** + * Creates an instance of RunStepCodeInterpreterToolCallOutput class. + */ + @Generated + protected RunStepCodeInterpreterToolCallOutput() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepCodeInterpreterToolCallOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepCodeInterpreterToolCallOutput if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the RunStepCodeInterpreterToolCallOutput. + */ + @Generated + public static RunStepCodeInterpreterToolCallOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("logs".equals(discriminatorValue)) { + return RunStepCodeInterpreterLogOutput.fromJson(readerToUse.reset()); + } else if ("image".equals(discriminatorValue)) { + return RunStepCodeInterpreterImageOutput.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static RunStepCodeInterpreterToolCallOutput fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepCodeInterpreterToolCallOutput deserializedRunStepCodeInterpreterToolCallOutput + = new RunStepCodeInterpreterToolCallOutput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedRunStepCodeInterpreterToolCallOutput.type = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedRunStepCodeInterpreterToolCallOutput; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCompletionUsage.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCompletionUsage.java new file mode 100644 index 000000000000..af9e86167348 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepCompletionUsage.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Usage statistics related to the run step. + */ +@Immutable +public final class RunStepCompletionUsage implements JsonSerializable { + + /* + * Number of completion tokens used over the course of the run step. + */ + @Generated + private final long completionTokens; + + /* + * Number of prompt tokens used over the course of the run step. + */ + @Generated + private final long promptTokens; + + /* + * Total number of tokens used (prompt + completion). + */ + @Generated + private final long totalTokens; + + /** + * Creates an instance of RunStepCompletionUsage class. + * + * @param completionTokens the completionTokens value to set. + * @param promptTokens the promptTokens value to set. + * @param totalTokens the totalTokens value to set. + */ + @Generated + private RunStepCompletionUsage(long completionTokens, long promptTokens, long totalTokens) { + this.completionTokens = completionTokens; + this.promptTokens = promptTokens; + this.totalTokens = totalTokens; + } + + /** + * Get the completionTokens property: Number of completion tokens used over the course of the run step. + * + * @return the completionTokens value. + */ + @Generated + public long getCompletionTokens() { + return this.completionTokens; + } + + /** + * Get the promptTokens property: Number of prompt tokens used over the course of the run step. + * + * @return the promptTokens value. + */ + @Generated + public long getPromptTokens() { + return this.promptTokens; + } + + /** + * Get the totalTokens property: Total number of tokens used (prompt + completion). + * + * @return the totalTokens value. + */ + @Generated + public long getTotalTokens() { + return this.totalTokens; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeLongField("completion_tokens", this.completionTokens); + jsonWriter.writeLongField("prompt_tokens", this.promptTokens); + jsonWriter.writeLongField("total_tokens", this.totalTokens); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepCompletionUsage from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepCompletionUsage if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepCompletionUsage. + */ + @Generated + public static RunStepCompletionUsage fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + long completionTokens = 0L; + long promptTokens = 0L; + long totalTokens = 0L; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("completion_tokens".equals(fieldName)) { + completionTokens = reader.getLong(); + } else if ("prompt_tokens".equals(fieldName)) { + promptTokens = reader.getLong(); + } else if ("total_tokens".equals(fieldName)) { + totalTokens = reader.getLong(); + } else { + reader.skipChildren(); + } + } + return new RunStepCompletionUsage(completionTokens, promptTokens, totalTokens); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDelta.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDelta.java new file mode 100644 index 000000000000..20944755d986 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDelta.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents the delta payload in a streaming run step delta chunk. + */ +@Immutable +public final class RunStepDelta implements JsonSerializable { + + /* + * The details of the run step. + */ + @Generated + private RunStepDeltaDetail stepDetails; + + /** + * Creates an instance of RunStepDelta class. + */ + @Generated + private RunStepDelta() { + } + + /** + * Get the stepDetails property: The details of the run step. + * + * @return the stepDetails value. + */ + @Generated + public RunStepDeltaDetail getStepDetails() { + return this.stepDetails; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("step_details", this.stepDetails); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDelta from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDelta if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the RunStepDelta. + */ + @Generated + public static RunStepDelta fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepDelta deserializedRunStepDelta = new RunStepDelta(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("step_details".equals(fieldName)) { + deserializedRunStepDelta.stepDetails = RunStepDeltaDetail.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedRunStepDelta; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaChunk.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaChunk.java new file mode 100644 index 000000000000..503fdecd4746 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaChunk.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a run step delta i.e. any changed fields on a run step during streaming. + */ +@Immutable +public final class RunStepDeltaChunk implements JsonSerializable { + + /* + * The identifier of the run step, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The object type, which is always `thread.run.step.delta`. + */ + @Generated + private final String object = "thread.run.step.delta"; + + /* + * The delta containing the fields that have changed on the run step. + */ + @Generated + private final RunStepDelta delta; + + /** + * Creates an instance of RunStepDeltaChunk class. + * + * @param id the id value to set. + * @param delta the delta value to set. + */ + @Generated + private RunStepDeltaChunk(String id, RunStepDelta delta) { + this.id = id; + this.delta = delta; + } + + /** + * Get the id property: The identifier of the run step, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the object property: The object type, which is always `thread.run.step.delta`. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the delta property: The delta containing the fields that have changed on the run step. + * + * @return the delta value. + */ + @Generated + public RunStepDelta getDelta() { + return this.delta; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeJsonField("delta", this.delta); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaChunk from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaChunk if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepDeltaChunk. + */ + @Generated + public static RunStepDeltaChunk fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + RunStepDelta delta = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("delta".equals(fieldName)) { + delta = RunStepDelta.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new RunStepDeltaChunk(id, delta); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterDetailItemObject.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterDetailItemObject.java new file mode 100644 index 000000000000..33257a047410 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterDetailItemObject.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Represents the Code Interpreter tool call data in a streaming run step's tool calls. + */ +@Immutable +public final class RunStepDeltaCodeInterpreterDetailItemObject + implements JsonSerializable { + + /* + * The input into the Code Interpreter tool call. + */ + @Generated + private String input; + + /* + * The outputs from the Code Interpreter tool call. Code Interpreter can output one or more + * items, including text (`logs`) or images (`image`). Each of these are represented by a + * different object type. + */ + @Generated + private List outputs; + + /** + * Creates an instance of RunStepDeltaCodeInterpreterDetailItemObject class. + */ + @Generated + private RunStepDeltaCodeInterpreterDetailItemObject() { + } + + /** + * Get the input property: The input into the Code Interpreter tool call. + * + * @return the input value. + */ + @Generated + public String getInput() { + return this.input; + } + + /** + * Get the outputs property: The outputs from the Code Interpreter tool call. Code Interpreter can output one or + * more + * items, including text (`logs`) or images (`image`). Each of these are represented by a + * different object type. + * + * @return the outputs value. + */ + @Generated + public List getOutputs() { + return this.outputs; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("input", this.input); + jsonWriter.writeArrayField("outputs", this.outputs, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaCodeInterpreterDetailItemObject from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaCodeInterpreterDetailItemObject if the JsonReader was pointing to an instance + * of it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the RunStepDeltaCodeInterpreterDetailItemObject. + */ + @Generated + public static RunStepDeltaCodeInterpreterDetailItemObject fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepDeltaCodeInterpreterDetailItemObject deserializedRunStepDeltaCodeInterpreterDetailItemObject + = new RunStepDeltaCodeInterpreterDetailItemObject(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("input".equals(fieldName)) { + deserializedRunStepDeltaCodeInterpreterDetailItemObject.input = reader.getString(); + } else if ("outputs".equals(fieldName)) { + List outputs + = reader.readArray(reader1 -> RunStepDeltaCodeInterpreterOutput.fromJson(reader1)); + deserializedRunStepDeltaCodeInterpreterDetailItemObject.outputs = outputs; + } else { + reader.skipChildren(); + } + } + return deserializedRunStepDeltaCodeInterpreterDetailItemObject; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterImageOutput.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterImageOutput.java new file mode 100644 index 000000000000..260a02319fd9 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterImageOutput.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents an image output as produced the Code interpreter tool and as represented in a streaming run step's delta + * tool calls collection. + */ +@Immutable +public final class RunStepDeltaCodeInterpreterImageOutput extends RunStepDeltaCodeInterpreterOutput { + + /* + * The type of the streaming run step tool call's Code Interpreter output. + */ + @Generated + private String type = "image"; + + /* + * The image data for the Code Interpreter tool call output. + */ + @Generated + private RunStepDeltaCodeInterpreterImageOutputObject image; + + /** + * Creates an instance of RunStepDeltaCodeInterpreterImageOutput class. + * + * @param index the index value to set. + */ + @Generated + private RunStepDeltaCodeInterpreterImageOutput(int index) { + super(index); + } + + /** + * Get the type property: The type of the streaming run step tool call's Code Interpreter output. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the image property: The image data for the Code Interpreter tool call output. + * + * @return the image value. + */ + @Generated + public RunStepDeltaCodeInterpreterImageOutputObject getImage() { + return this.image; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", getIndex()); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("image", this.image); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaCodeInterpreterImageOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaCodeInterpreterImageOutput if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepDeltaCodeInterpreterImageOutput. + */ + @Generated + public static RunStepDeltaCodeInterpreterImageOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String type = "image"; + RunStepDeltaCodeInterpreterImageOutputObject image = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("image".equals(fieldName)) { + image = RunStepDeltaCodeInterpreterImageOutputObject.fromJson(reader); + } else { + reader.skipChildren(); + } + } + RunStepDeltaCodeInterpreterImageOutput deserializedRunStepDeltaCodeInterpreterImageOutput + = new RunStepDeltaCodeInterpreterImageOutput(index); + deserializedRunStepDeltaCodeInterpreterImageOutput.type = type; + deserializedRunStepDeltaCodeInterpreterImageOutput.image = image; + return deserializedRunStepDeltaCodeInterpreterImageOutput; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterImageOutputObject.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterImageOutputObject.java new file mode 100644 index 000000000000..f812500d8706 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterImageOutputObject.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents the data for a streaming run step's Code Interpreter tool call image output. + */ +@Immutable +public final class RunStepDeltaCodeInterpreterImageOutputObject + implements JsonSerializable { + + /* + * The file ID for the image. + */ + @Generated + private String fileId; + + /** + * Creates an instance of RunStepDeltaCodeInterpreterImageOutputObject class. + */ + @Generated + private RunStepDeltaCodeInterpreterImageOutputObject() { + } + + /** + * Get the fileId property: The file ID for the image. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaCodeInterpreterImageOutputObject from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaCodeInterpreterImageOutputObject if the JsonReader was pointing to an instance + * of it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the RunStepDeltaCodeInterpreterImageOutputObject. + */ + @Generated + public static RunStepDeltaCodeInterpreterImageOutputObject fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepDeltaCodeInterpreterImageOutputObject deserializedRunStepDeltaCodeInterpreterImageOutputObject + = new RunStepDeltaCodeInterpreterImageOutputObject(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + deserializedRunStepDeltaCodeInterpreterImageOutputObject.fileId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedRunStepDeltaCodeInterpreterImageOutputObject; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterLogOutput.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterLogOutput.java new file mode 100644 index 000000000000..227584862596 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterLogOutput.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a log output as produced by the Code Interpreter tool and as represented in a streaming run step's delta + * tool calls collection. + */ +@Immutable +public final class RunStepDeltaCodeInterpreterLogOutput extends RunStepDeltaCodeInterpreterOutput { + + /* + * The type of the streaming run step tool call's Code Interpreter output. + */ + @Generated + private String type = "logs"; + + /* + * The text output from the Code Interpreter tool call. + */ + @Generated + private String logs; + + /** + * Creates an instance of RunStepDeltaCodeInterpreterLogOutput class. + * + * @param index the index value to set. + */ + @Generated + private RunStepDeltaCodeInterpreterLogOutput(int index) { + super(index); + } + + /** + * Get the type property: The type of the streaming run step tool call's Code Interpreter output. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the logs property: The text output from the Code Interpreter tool call. + * + * @return the logs value. + */ + @Generated + public String getLogs() { + return this.logs; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", getIndex()); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeStringField("logs", this.logs); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaCodeInterpreterLogOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaCodeInterpreterLogOutput if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepDeltaCodeInterpreterLogOutput. + */ + @Generated + public static RunStepDeltaCodeInterpreterLogOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String type = "logs"; + String logs = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("logs".equals(fieldName)) { + logs = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepDeltaCodeInterpreterLogOutput deserializedRunStepDeltaCodeInterpreterLogOutput + = new RunStepDeltaCodeInterpreterLogOutput(index); + deserializedRunStepDeltaCodeInterpreterLogOutput.type = type; + deserializedRunStepDeltaCodeInterpreterLogOutput.logs = logs; + return deserializedRunStepDeltaCodeInterpreterLogOutput; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterOutput.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterOutput.java new file mode 100644 index 000000000000..091d1622cac3 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterOutput.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The abstract base representation of a streaming run step tool call's Code Interpreter tool output. + */ +@Immutable +public class RunStepDeltaCodeInterpreterOutput implements JsonSerializable { + + /* + * The type of the streaming run step tool call's Code Interpreter output. + */ + @Generated + private String type = "RunStepDeltaCodeInterpreterOutput"; + + /* + * The index of the output in the streaming run step tool call's Code Interpreter outputs array. + */ + @Generated + private final int index; + + /** + * Creates an instance of RunStepDeltaCodeInterpreterOutput class. + * + * @param index the index value to set. + */ + @Generated + protected RunStepDeltaCodeInterpreterOutput(int index) { + this.index = index; + } + + /** + * Get the type property: The type of the streaming run step tool call's Code Interpreter output. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the index property: The index of the output in the streaming run step tool call's Code Interpreter outputs + * array. + * + * @return the index value. + */ + @Generated + public int getIndex() { + return this.index; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaCodeInterpreterOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaCodeInterpreterOutput if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepDeltaCodeInterpreterOutput. + */ + @Generated + public static RunStepDeltaCodeInterpreterOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("logs".equals(discriminatorValue)) { + return RunStepDeltaCodeInterpreterLogOutput.fromJson(readerToUse.reset()); + } else if ("image".equals(discriminatorValue)) { + return RunStepDeltaCodeInterpreterImageOutput.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static RunStepDeltaCodeInterpreterOutput fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepDeltaCodeInterpreterOutput deserializedRunStepDeltaCodeInterpreterOutput + = new RunStepDeltaCodeInterpreterOutput(index); + deserializedRunStepDeltaCodeInterpreterOutput.type = type; + return deserializedRunStepDeltaCodeInterpreterOutput; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterToolCall.java new file mode 100644 index 000000000000..32641216773a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaCodeInterpreterToolCall.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a Code Interpreter tool call within a streaming run step's tool call details. + */ +@Immutable +public final class RunStepDeltaCodeInterpreterToolCall extends RunStepDeltaToolCall { + + /* + * The type of the tool call detail item in a streaming run step's details. + */ + @Generated + private String type = "code_interpreter"; + + /* + * The Code Interpreter data for the tool call. + */ + @Generated + private RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter; + + /** + * Creates an instance of RunStepDeltaCodeInterpreterToolCall class. + * + * @param index the index value to set. + * @param id the id value to set. + */ + @Generated + private RunStepDeltaCodeInterpreterToolCall(int index, String id) { + super(index, id); + } + + /** + * Get the type property: The type of the tool call detail item in a streaming run step's details. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the codeInterpreter property: The Code Interpreter data for the tool call. + * + * @return the codeInterpreter value. + */ + @Generated + public RunStepDeltaCodeInterpreterDetailItemObject getCodeInterpreter() { + return this.codeInterpreter; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", getIndex()); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("code_interpreter", this.codeInterpreter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaCodeInterpreterToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaCodeInterpreterToolCall if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepDeltaCodeInterpreterToolCall. + */ + @Generated + public static RunStepDeltaCodeInterpreterToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String id = null; + String type = "code_interpreter"; + RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("code_interpreter".equals(fieldName)) { + codeInterpreter = RunStepDeltaCodeInterpreterDetailItemObject.fromJson(reader); + } else { + reader.skipChildren(); + } + } + RunStepDeltaCodeInterpreterToolCall deserializedRunStepDeltaCodeInterpreterToolCall + = new RunStepDeltaCodeInterpreterToolCall(index, id); + deserializedRunStepDeltaCodeInterpreterToolCall.type = type; + deserializedRunStepDeltaCodeInterpreterToolCall.codeInterpreter = codeInterpreter; + return deserializedRunStepDeltaCodeInterpreterToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaDetail.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaDetail.java new file mode 100644 index 000000000000..7004419fa768 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaDetail.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a single run step detail item in a streaming run step's delta payload. + */ +@Immutable +public class RunStepDeltaDetail implements JsonSerializable { + + /* + * The object type for the run step detail object. + */ + @Generated + private String type = "RunStepDeltaDetail"; + + /** + * Creates an instance of RunStepDeltaDetail class. + */ + @Generated + protected RunStepDeltaDetail() { + } + + /** + * Get the type property: The object type for the run step detail object. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaDetail from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaDetail if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the RunStepDeltaDetail. + */ + @Generated + public static RunStepDeltaDetail fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("message_creation".equals(discriminatorValue)) { + return RunStepDeltaMessageCreation.fromJson(readerToUse.reset()); + } else if ("tool_calls".equals(discriminatorValue)) { + return RunStepDeltaToolCallObject.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static RunStepDeltaDetail fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepDeltaDetail deserializedRunStepDeltaDetail = new RunStepDeltaDetail(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedRunStepDeltaDetail.type = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedRunStepDeltaDetail; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFileSearchToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFileSearchToolCall.java new file mode 100644 index 000000000000..d5497ad8af0d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFileSearchToolCall.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a file search tool call within a streaming run step's tool call details. + */ +@Immutable +public final class RunStepDeltaFileSearchToolCall extends RunStepDeltaToolCall { + + /* + * The type of the tool call detail item in a streaming run step's details. + */ + @Generated + private String type = "file_search"; + + /* + * Reserved for future use. + */ + @Generated + private RunStepFileSearchToolCallResults fileSearch; + + /** + * Creates an instance of RunStepDeltaFileSearchToolCall class. + * + * @param index the index value to set. + * @param id the id value to set. + */ + @Generated + private RunStepDeltaFileSearchToolCall(int index, String id) { + super(index, id); + } + + /** + * Get the type property: The type of the tool call detail item in a streaming run step's details. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the fileSearch property: Reserved for future use. + * + * @return the fileSearch value. + */ + @Generated + public RunStepFileSearchToolCallResults getFileSearch() { + return this.fileSearch; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", getIndex()); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("file_search", this.fileSearch); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaFileSearchToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaFileSearchToolCall if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepDeltaFileSearchToolCall. + */ + @Generated + public static RunStepDeltaFileSearchToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String id = null; + String type = "file_search"; + RunStepFileSearchToolCallResults fileSearch = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("file_search".equals(fieldName)) { + fileSearch = RunStepFileSearchToolCallResults.fromJson(reader); + } else { + reader.skipChildren(); + } + } + RunStepDeltaFileSearchToolCall deserializedRunStepDeltaFileSearchToolCall + = new RunStepDeltaFileSearchToolCall(index, id); + deserializedRunStepDeltaFileSearchToolCall.type = type; + deserializedRunStepDeltaFileSearchToolCall.fileSearch = fileSearch; + return deserializedRunStepDeltaFileSearchToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFunction.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFunction.java new file mode 100644 index 000000000000..05b4807e2fd5 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFunction.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents the function data in a streaming run step delta's function tool call. + */ +@Immutable +public final class RunStepDeltaFunction implements JsonSerializable { + + /* + * The name of the function. + */ + @Generated + private String name; + + /* + * The arguments passed to the function as input. + */ + @Generated + private String arguments; + + /* + * The output of the function, null if outputs have not yet been submitted. + */ + @Generated + private String output; + + /** + * Creates an instance of RunStepDeltaFunction class. + */ + @Generated + private RunStepDeltaFunction() { + } + + /** + * Get the name property: The name of the function. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the arguments property: The arguments passed to the function as input. + * + * @return the arguments value. + */ + @Generated + public String getArguments() { + return this.arguments; + } + + /** + * Get the output property: The output of the function, null if outputs have not yet been submitted. + * + * @return the output value. + */ + @Generated + public String getOutput() { + return this.output; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("arguments", this.arguments); + jsonWriter.writeStringField("output", this.output); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaFunction from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaFunction if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the RunStepDeltaFunction. + */ + @Generated + public static RunStepDeltaFunction fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepDeltaFunction deserializedRunStepDeltaFunction = new RunStepDeltaFunction(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("name".equals(fieldName)) { + deserializedRunStepDeltaFunction.name = reader.getString(); + } else if ("arguments".equals(fieldName)) { + deserializedRunStepDeltaFunction.arguments = reader.getString(); + } else if ("output".equals(fieldName)) { + deserializedRunStepDeltaFunction.output = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedRunStepDeltaFunction; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFunctionToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFunctionToolCall.java new file mode 100644 index 000000000000..e8de6c35a8d6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaFunctionToolCall.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a function tool call within a streaming run step's tool call details. + */ +@Immutable +public final class RunStepDeltaFunctionToolCall extends RunStepDeltaToolCall { + + /* + * The type of the tool call detail item in a streaming run step's details. + */ + @Generated + private String type = "function"; + + /* + * The function data for the tool call. + */ + @Generated + private RunStepDeltaFunction function; + + /** + * Creates an instance of RunStepDeltaFunctionToolCall class. + * + * @param index the index value to set. + * @param id the id value to set. + */ + @Generated + private RunStepDeltaFunctionToolCall(int index, String id) { + super(index, id); + } + + /** + * Get the type property: The type of the tool call detail item in a streaming run step's details. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the function property: The function data for the tool call. + * + * @return the function value. + */ + @Generated + public RunStepDeltaFunction getFunction() { + return this.function; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", getIndex()); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("function", this.function); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaFunctionToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaFunctionToolCall if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepDeltaFunctionToolCall. + */ + @Generated + public static RunStepDeltaFunctionToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String id = null; + String type = "function"; + RunStepDeltaFunction function = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else if ("function".equals(fieldName)) { + function = RunStepDeltaFunction.fromJson(reader); + } else { + reader.skipChildren(); + } + } + RunStepDeltaFunctionToolCall deserializedRunStepDeltaFunctionToolCall + = new RunStepDeltaFunctionToolCall(index, id); + deserializedRunStepDeltaFunctionToolCall.type = type; + deserializedRunStepDeltaFunctionToolCall.function = function; + return deserializedRunStepDeltaFunctionToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaMessageCreation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaMessageCreation.java new file mode 100644 index 000000000000..8e98e5ba0bf7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaMessageCreation.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents a message creation within a streaming run step delta. + */ +@Immutable +public final class RunStepDeltaMessageCreation extends RunStepDeltaDetail { + + /* + * The object type for the run step detail object. + */ + @Generated + private String type = "message_creation"; + + /* + * The message creation data. + */ + @Generated + private RunStepDeltaMessageCreationObject messageCreation; + + /** + * Creates an instance of RunStepDeltaMessageCreation class. + */ + @Generated + private RunStepDeltaMessageCreation() { + } + + /** + * Get the type property: The object type for the run step detail object. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the messageCreation property: The message creation data. + * + * @return the messageCreation value. + */ + @Generated + public RunStepDeltaMessageCreationObject getMessageCreation() { + return this.messageCreation; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeJsonField("message_creation", this.messageCreation); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaMessageCreation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaMessageCreation if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the RunStepDeltaMessageCreation. + */ + @Generated + public static RunStepDeltaMessageCreation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepDeltaMessageCreation deserializedRunStepDeltaMessageCreation = new RunStepDeltaMessageCreation(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedRunStepDeltaMessageCreation.type = reader.getString(); + } else if ("message_creation".equals(fieldName)) { + deserializedRunStepDeltaMessageCreation.messageCreation + = RunStepDeltaMessageCreationObject.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedRunStepDeltaMessageCreation; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaMessageCreationObject.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaMessageCreationObject.java new file mode 100644 index 000000000000..3314284a7b8e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaMessageCreationObject.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Represents the data within a streaming run step message creation response object. + */ +@Immutable +public final class RunStepDeltaMessageCreationObject implements JsonSerializable { + + /* + * The ID of the newly-created message. + */ + @Generated + private String messageId; + + /** + * Creates an instance of RunStepDeltaMessageCreationObject class. + */ + @Generated + private RunStepDeltaMessageCreationObject() { + } + + /** + * Get the messageId property: The ID of the newly-created message. + * + * @return the messageId value. + */ + @Generated + public String getMessageId() { + return this.messageId; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("message_id", this.messageId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaMessageCreationObject from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaMessageCreationObject if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the RunStepDeltaMessageCreationObject. + */ + @Generated + public static RunStepDeltaMessageCreationObject fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepDeltaMessageCreationObject deserializedRunStepDeltaMessageCreationObject + = new RunStepDeltaMessageCreationObject(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("message_id".equals(fieldName)) { + deserializedRunStepDeltaMessageCreationObject.messageId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedRunStepDeltaMessageCreationObject; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaToolCall.java new file mode 100644 index 000000000000..05c05cf876b5 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaToolCall.java @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The abstract base representation of a single tool call within a streaming run step's delta tool call details. + */ +@Immutable +public class RunStepDeltaToolCall implements JsonSerializable { + + /* + * The type of the tool call detail item in a streaming run step's details. + */ + @Generated + private String type = "RunStepDeltaToolCall"; + + /* + * The index of the tool call detail in the run step's tool_calls array. + */ + @Generated + private final int index; + + /* + * The ID of the tool call, used when submitting outputs to the run. + */ + @Generated + private final String id; + + /** + * Creates an instance of RunStepDeltaToolCall class. + * + * @param index the index value to set. + * @param id the id value to set. + */ + @Generated + protected RunStepDeltaToolCall(int index, String id) { + this.index = index; + this.id = id; + } + + /** + * Get the type property: The type of the tool call detail item in a streaming run step's details. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the index property: The index of the tool call detail in the run step's tool_calls array. + * + * @return the index value. + */ + @Generated + public int getIndex() { + return this.index; + } + + /** + * Get the id property: The ID of the tool call, used when submitting outputs to the run. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaToolCall if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepDeltaToolCall. + */ + @Generated + public static RunStepDeltaToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("function".equals(discriminatorValue)) { + return RunStepDeltaFunctionToolCall.fromJson(readerToUse.reset()); + } else if ("file_search".equals(discriminatorValue)) { + return RunStepDeltaFileSearchToolCall.fromJson(readerToUse.reset()); + } else if ("code_interpreter".equals(discriminatorValue)) { + return RunStepDeltaCodeInterpreterToolCall.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static RunStepDeltaToolCall fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int index = 0; + String id = null; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepDeltaToolCall deserializedRunStepDeltaToolCall = new RunStepDeltaToolCall(index, id); + deserializedRunStepDeltaToolCall.type = type; + return deserializedRunStepDeltaToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaToolCallObject.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaToolCallObject.java new file mode 100644 index 000000000000..fed0dc1a275b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDeltaToolCallObject.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Represents an invocation of tool calls as part of a streaming run step. + */ +@Immutable +public final class RunStepDeltaToolCallObject extends RunStepDeltaDetail { + + /* + * The object type for the run step detail object. + */ + @Generated + private String type = "tool_calls"; + + /* + * The collection of tool calls for the tool call detail item. + */ + @Generated + private List toolCalls; + + /** + * Creates an instance of RunStepDeltaToolCallObject class. + */ + @Generated + private RunStepDeltaToolCallObject() { + } + + /** + * Get the type property: The object type for the run step detail object. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the toolCalls property: The collection of tool calls for the tool call detail item. + * + * @return the toolCalls value. + */ + @Generated + public List getToolCalls() { + return this.toolCalls; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + jsonWriter.writeArrayField("tool_calls", this.toolCalls, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDeltaToolCallObject from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDeltaToolCallObject if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the RunStepDeltaToolCallObject. + */ + @Generated + public static RunStepDeltaToolCallObject fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepDeltaToolCallObject deserializedRunStepDeltaToolCallObject = new RunStepDeltaToolCallObject(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedRunStepDeltaToolCallObject.type = reader.getString(); + } else if ("tool_calls".equals(fieldName)) { + List toolCalls + = reader.readArray(reader1 -> RunStepDeltaToolCall.fromJson(reader1)); + deserializedRunStepDeltaToolCallObject.toolCalls = toolCalls; + } else { + reader.skipChildren(); + } + } + return deserializedRunStepDeltaToolCallObject; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDetails.java new file mode 100644 index 000000000000..f0a487ee3dc8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepDetails.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An abstract representation of the details for a run step. + */ +@Immutable +public class RunStepDetails implements JsonSerializable { + + /* + * The object type. + */ + @Generated + private RunStepType type = RunStepType.fromString("RunStepDetails"); + + /** + * Creates an instance of RunStepDetails class. + */ + @Generated + protected RunStepDetails() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + public RunStepType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepDetails if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the RunStepDetails. + */ + @Generated + public static RunStepDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("message_creation".equals(discriminatorValue)) { + return RunStepMessageCreationDetails.fromJson(readerToUse.reset()); + } else if ("tool_calls".equals(discriminatorValue)) { + return RunStepToolCallDetails.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static RunStepDetails fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepDetails deserializedRunStepDetails = new RunStepDetails(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedRunStepDetails.type = RunStepType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedRunStepDetails; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepError.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepError.java new file mode 100644 index 000000000000..01b9c9f3d8a2 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepError.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The error information associated with a failed run step. + */ +@Immutable +public final class RunStepError implements JsonSerializable { + + /* + * The error code for this error. + */ + @Generated + private final RunStepErrorCode code; + + /* + * The human-readable text associated with this error. + */ + @Generated + private final String message; + + /** + * Creates an instance of RunStepError class. + * + * @param code the code value to set. + * @param message the message value to set. + */ + @Generated + private RunStepError(RunStepErrorCode code, String message) { + this.code = code; + this.message = message; + } + + /** + * Get the code property: The error code for this error. + * + * @return the code value. + */ + @Generated + public RunStepErrorCode getCode() { + return this.code; + } + + /** + * Get the message property: The human-readable text associated with this error. + * + * @return the message value. + */ + @Generated + public String getMessage() { + return this.message; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("code", this.code == null ? null : this.code.toString()); + jsonWriter.writeStringField("message", this.message); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepError if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepError. + */ + @Generated + public static RunStepError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepErrorCode code = null; + String message = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("code".equals(fieldName)) { + code = RunStepErrorCode.fromString(reader.getString()); + } else if ("message".equals(fieldName)) { + message = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new RunStepError(code, message); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepErrorCode.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepErrorCode.java new file mode 100644 index 000000000000..d0f58846a299 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepErrorCode.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Possible error code values attributable to a failed run step. + */ +public final class RunStepErrorCode extends ExpandableStringEnum { + + /** + * Represents a server error. + */ + @Generated + public static final RunStepErrorCode SERVER_ERROR = fromString("server_error"); + + /** + * Represents an error indicating configured rate limits were exceeded. + */ + @Generated + public static final RunStepErrorCode RATE_LIMIT_EXCEEDED = fromString("rate_limit_exceeded"); + + /** + * Creates a new instance of RunStepErrorCode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public RunStepErrorCode() { + } + + /** + * Creates or finds a RunStepErrorCode from its string representation. + * + * @param name a name to look for. + * @return the corresponding RunStepErrorCode. + */ + @Generated + public static RunStepErrorCode fromString(String name) { + return fromString(name, RunStepErrorCode.class); + } + + /** + * Gets known RunStepErrorCode values. + * + * @return known RunStepErrorCode values. + */ + @Generated + public static Collection values() { + return values(RunStepErrorCode.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCall.java new file mode 100644 index 000000000000..7e88a3177e18 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCall.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A record of a call to a file search tool, issued by the model in evaluation of a defined tool, that represents + * executed file search. + */ +@Immutable +public final class RunStepFileSearchToolCall extends RunStepToolCall { + + /* + * The object type. + */ + @Generated + private String type = "file_search"; + + /* + * For now, this is always going to be an empty object. + */ + @Generated + private final RunStepFileSearchToolCallResults fileSearch; + + /** + * Creates an instance of RunStepFileSearchToolCall class. + * + * @param id the id value to set. + * @param fileSearch the fileSearch value to set. + */ + @Generated + private RunStepFileSearchToolCall(String id, RunStepFileSearchToolCallResults fileSearch) { + super(id); + this.fileSearch = fileSearch; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the fileSearch property: For now, this is always going to be an empty object. + * + * @return the fileSearch value. + */ + @Generated + public RunStepFileSearchToolCallResults getFileSearch() { + return this.fileSearch; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeJsonField("file_search", this.fileSearch); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepFileSearchToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepFileSearchToolCall if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepFileSearchToolCall. + */ + @Generated + public static RunStepFileSearchToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + RunStepFileSearchToolCallResults fileSearch = null; + String type = "file_search"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("file_search".equals(fieldName)) { + fileSearch = RunStepFileSearchToolCallResults.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepFileSearchToolCall deserializedRunStepFileSearchToolCall + = new RunStepFileSearchToolCall(id, fileSearch); + deserializedRunStepFileSearchToolCall.type = type; + return deserializedRunStepFileSearchToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCallResult.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCallResult.java new file mode 100644 index 000000000000..802b8d0dc817 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCallResult.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * File search tool call result. + */ +@Immutable +public final class RunStepFileSearchToolCallResult implements JsonSerializable { + + /* + * The ID of the file that result was found in. + */ + @Generated + private final String fileId; + + /* + * The name of the file that result was found in. + */ + @Generated + private final String fileName; + + /* + * The score of the result. All values must be a floating point number between 0 and 1. + */ + @Generated + private final double score; + + /* + * The content of the result that was found. The content is only included if requested via the include query + * parameter. + */ + @Generated + private List content; + + /** + * Creates an instance of RunStepFileSearchToolCallResult class. + * + * @param fileId the fileId value to set. + * @param fileName the fileName value to set. + * @param score the score value to set. + */ + @Generated + private RunStepFileSearchToolCallResult(String fileId, String fileName, double score) { + this.fileId = fileId; + this.fileName = fileName; + this.score = score; + } + + /** + * Get the fileId property: The ID of the file that result was found in. + * + * @return the fileId value. + */ + @Generated + public String getFileId() { + return this.fileId; + } + + /** + * Get the fileName property: The name of the file that result was found in. + * + * @return the fileName value. + */ + @Generated + public String getFileName() { + return this.fileName; + } + + /** + * Get the score property: The score of the result. All values must be a floating point number between 0 and 1. + * + * @return the score value. + */ + @Generated + public double getScore() { + return this.score; + } + + /** + * Get the content property: The content of the result that was found. The content is only included if requested via + * the include query parameter. + * + * @return the content value. + */ + @Generated + public List getContent() { + return this.content; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("file_id", this.fileId); + jsonWriter.writeStringField("file_name", this.fileName); + jsonWriter.writeDoubleField("score", this.score); + jsonWriter.writeArrayField("content", this.content, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepFileSearchToolCallResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepFileSearchToolCallResult if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepFileSearchToolCallResult. + */ + @Generated + public static RunStepFileSearchToolCallResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String fileId = null; + String fileName = null; + double score = 0.0; + List content = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_id".equals(fieldName)) { + fileId = reader.getString(); + } else if ("file_name".equals(fieldName)) { + fileName = reader.getString(); + } else if ("score".equals(fieldName)) { + score = reader.getDouble(); + } else if ("content".equals(fieldName)) { + content = reader.readArray(reader1 -> FileSearchToolCallContent.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + RunStepFileSearchToolCallResult deserializedRunStepFileSearchToolCallResult + = new RunStepFileSearchToolCallResult(fileId, fileName, score); + deserializedRunStepFileSearchToolCallResult.content = content; + return deserializedRunStepFileSearchToolCallResult; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCallResults.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCallResults.java new file mode 100644 index 000000000000..940c04098ee7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFileSearchToolCallResults.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The results of the file search. + */ +@Immutable +public final class RunStepFileSearchToolCallResults implements JsonSerializable { + + /* + * Ranking options for file search. + */ + @Generated + private FileSearchRankingOptions rankingOptions; + + /* + * The array of a file search results + */ + @Generated + private final List results; + + /** + * Creates an instance of RunStepFileSearchToolCallResults class. + * + * @param results the results value to set. + */ + @Generated + private RunStepFileSearchToolCallResults(List results) { + this.results = results; + } + + /** + * Get the rankingOptions property: Ranking options for file search. + * + * @return the rankingOptions value. + */ + @Generated + public FileSearchRankingOptions getRankingOptions() { + return this.rankingOptions; + } + + /** + * Get the results property: The array of a file search results. + * + * @return the results value. + */ + @Generated + public List getResults() { + return this.results; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("results", this.results, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("ranking_options", this.rankingOptions); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepFileSearchToolCallResults from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepFileSearchToolCallResults if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepFileSearchToolCallResults. + */ + @Generated + public static RunStepFileSearchToolCallResults fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List results = null; + FileSearchRankingOptions rankingOptions = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("results".equals(fieldName)) { + results = reader.readArray(reader1 -> RunStepFileSearchToolCallResult.fromJson(reader1)); + } else if ("ranking_options".equals(fieldName)) { + rankingOptions = FileSearchRankingOptions.fromJson(reader); + } else { + reader.skipChildren(); + } + } + RunStepFileSearchToolCallResults deserializedRunStepFileSearchToolCallResults + = new RunStepFileSearchToolCallResults(results); + deserializedRunStepFileSearchToolCallResults.rankingOptions = rankingOptions; + return deserializedRunStepFileSearchToolCallResults; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFunctionToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFunctionToolCall.java new file mode 100644 index 000000000000..852f05c932bf --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFunctionToolCall.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * 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. + */ +@Immutable +public final class RunStepFunctionToolCall extends RunStepToolCall { + + /* + * The object type. + */ + @Generated + private String type = "function"; + + /* + * The detailed information about the function called by the model. + */ + @Generated + private final RunStepFunctionToolCallDetails function; + + /** + * Creates an instance of RunStepFunctionToolCall class. + * + * @param id the id value to set. + * @param function the function value to set. + */ + @Generated + private RunStepFunctionToolCall(String id, RunStepFunctionToolCallDetails function) { + super(id); + this.function = function; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the function property: The detailed information about the function called by the model. + * + * @return the function value. + */ + @Generated + public RunStepFunctionToolCallDetails getFunction() { + return this.function; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeJsonField("function", this.function); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepFunctionToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepFunctionToolCall if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepFunctionToolCall. + */ + @Generated + public static RunStepFunctionToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + RunStepFunctionToolCallDetails function = null; + String type = "function"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("function".equals(fieldName)) { + function = RunStepFunctionToolCallDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepFunctionToolCall deserializedRunStepFunctionToolCall = new RunStepFunctionToolCall(id, function); + deserializedRunStepFunctionToolCall.type = type; + return deserializedRunStepFunctionToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFunctionToolCallDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFunctionToolCallDetails.java new file mode 100644 index 000000000000..1a95a3a2ba69 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepFunctionToolCallDetails.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The detailed information about the function called by the model. + */ +@Immutable +public final class RunStepFunctionToolCallDetails implements JsonSerializable { + + /* + * The name of the function. + */ + @Generated + private final String name; + + /* + * The arguments that the model requires are provided to the named function. + */ + @Generated + private final String arguments; + + /** + * Creates an instance of RunStepFunctionToolCallDetails class. + * + * @param name the name value to set. + * @param arguments the arguments value to set. + */ + @Generated + private RunStepFunctionToolCallDetails(String name, String arguments) { + this.name = name; + this.arguments = arguments; + } + + /** + * Get the name property: The name of the function. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the arguments property: The arguments that the model requires are provided to the named function. + * + * @return the arguments value. + */ + @Generated + public String getArguments() { + return this.arguments; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("arguments", this.arguments); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepFunctionToolCallDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepFunctionToolCallDetails if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepFunctionToolCallDetails. + */ + @Generated + public static RunStepFunctionToolCallDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String arguments = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("arguments".equals(fieldName)) { + arguments = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new RunStepFunctionToolCallDetails(name, arguments); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMessageCreationDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMessageCreationDetails.java new file mode 100644 index 000000000000..404924cb30a1 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMessageCreationDetails.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The detailed information associated with a message creation run step. + */ +@Immutable +public final class RunStepMessageCreationDetails extends RunStepDetails { + + /* + * The object type. + */ + @Generated + private RunStepType type = RunStepType.MESSAGE_CREATION; + + /* + * Information about the message creation associated with this run step. + */ + @Generated + private final RunStepMessageCreationReference messageCreation; + + /** + * Creates an instance of RunStepMessageCreationDetails class. + * + * @param messageCreation the messageCreation value to set. + */ + @Generated + private RunStepMessageCreationDetails(RunStepMessageCreationReference messageCreation) { + this.messageCreation = messageCreation; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public RunStepType getType() { + return this.type; + } + + /** + * Get the messageCreation property: Information about the message creation associated with this run step. + * + * @return the messageCreation value. + */ + @Generated + public RunStepMessageCreationReference getMessageCreation() { + return this.messageCreation; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("message_creation", this.messageCreation); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepMessageCreationDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepMessageCreationDetails if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepMessageCreationDetails. + */ + @Generated + public static RunStepMessageCreationDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RunStepMessageCreationReference messageCreation = null; + RunStepType type = RunStepType.MESSAGE_CREATION; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("message_creation".equals(fieldName)) { + messageCreation = RunStepMessageCreationReference.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = RunStepType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + RunStepMessageCreationDetails deserializedRunStepMessageCreationDetails + = new RunStepMessageCreationDetails(messageCreation); + deserializedRunStepMessageCreationDetails.type = type; + return deserializedRunStepMessageCreationDetails; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMessageCreationReference.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMessageCreationReference.java new file mode 100644 index 000000000000..c3da9e3d4879 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMessageCreationReference.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The details of a message created as a part of a run step. + */ +@Immutable +public final class RunStepMessageCreationReference implements JsonSerializable { + + /* + * The ID of the message created by this run step. + */ + @Generated + private final String messageId; + + /** + * Creates an instance of RunStepMessageCreationReference class. + * + * @param messageId the messageId value to set. + */ + @Generated + private RunStepMessageCreationReference(String messageId) { + this.messageId = messageId; + } + + /** + * Get the messageId property: The ID of the message created by this run step. + * + * @return the messageId value. + */ + @Generated + public String getMessageId() { + return this.messageId; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("message_id", this.messageId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepMessageCreationReference from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepMessageCreationReference if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepMessageCreationReference. + */ + @Generated + public static RunStepMessageCreationReference fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String messageId = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("message_id".equals(fieldName)) { + messageId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new RunStepMessageCreationReference(messageId); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMicrosoftFabricToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMicrosoftFabricToolCall.java new file mode 100644 index 000000000000..2e9e3ca05d98 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMicrosoftFabricToolCall.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * A record of a call to a Microsoft Fabric tool, issued by the model in evaluation of a defined tool, that represents + * executed Microsoft Fabric operations. + */ +@Immutable +public final class RunStepMicrosoftFabricToolCall extends RunStepToolCall { + + /* + * The object type. + */ + @Generated + private String type = "fabric_dataagent"; + + /* + * Reserved for future use. + */ + @Generated + private final Map microsoftFabric; + + /** + * Creates an instance of RunStepMicrosoftFabricToolCall class. + * + * @param id the id value to set. + * @param microsoftFabric the microsoftFabric value to set. + */ + @Generated + private RunStepMicrosoftFabricToolCall(String id, Map microsoftFabric) { + super(id); + this.microsoftFabric = microsoftFabric; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the microsoftFabric property: Reserved for future use. + * + * @return the microsoftFabric value. + */ + @Generated + public Map getMicrosoftFabric() { + return this.microsoftFabric; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeMapField("fabric_dataagent", this.microsoftFabric, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepMicrosoftFabricToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepMicrosoftFabricToolCall if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepMicrosoftFabricToolCall. + */ + @Generated + public static RunStepMicrosoftFabricToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + Map microsoftFabric = null; + String type = "fabric_dataagent"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("fabric_dataagent".equals(fieldName)) { + microsoftFabric = reader.readMap(reader1 -> reader1.getString()); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepMicrosoftFabricToolCall deserializedRunStepMicrosoftFabricToolCall + = new RunStepMicrosoftFabricToolCall(id, microsoftFabric); + deserializedRunStepMicrosoftFabricToolCall.type = type; + return deserializedRunStepMicrosoftFabricToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepOpenApiToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepOpenApiToolCall.java new file mode 100644 index 000000000000..2b5ef68eb0e0 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepOpenApiToolCall.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * A record of a call to an OpenAPI tool, issued by the model in evaluation of a defined tool, that represents + * executed OpenAPI operations. + */ +@Immutable +public final class RunStepOpenApiToolCall extends RunStepToolCall { + + /* + * The object type. + */ + @Generated + private String type = "openapi"; + + /* + * Reserved for future use. + */ + @Generated + private final Map openApi; + + /** + * Creates an instance of RunStepOpenApiToolCall class. + * + * @param id the id value to set. + * @param openApi the openApi value to set. + */ + @Generated + private RunStepOpenApiToolCall(String id, Map openApi) { + super(id); + this.openApi = openApi; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the openApi property: Reserved for future use. + * + * @return the openApi value. + */ + @Generated + public Map getOpenApi() { + return this.openApi; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeMapField("openapi", this.openApi, (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepOpenApiToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepOpenApiToolCall if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepOpenApiToolCall. + */ + @Generated + public static RunStepOpenApiToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + Map openApi = null; + String type = "openapi"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("openapi".equals(fieldName)) { + openApi = reader.readMap(reader1 -> reader1.getString()); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepOpenApiToolCall deserializedRunStepOpenApiToolCall = new RunStepOpenApiToolCall(id, openApi); + deserializedRunStepOpenApiToolCall.type = type; + return deserializedRunStepOpenApiToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepSharepointToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepSharepointToolCall.java new file mode 100644 index 000000000000..fad1bf5df004 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepSharepointToolCall.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * A record of a call to a SharePoint tool, issued by the model in evaluation of a defined tool, that represents + * executed SharePoint actions. + */ +@Immutable +public final class RunStepSharepointToolCall extends RunStepToolCall { + + /* + * The object type. + */ + @Generated + private String type = "sharepoint_grounding"; + + /* + * Reserved for future use. + */ + @Generated + private final Map sharePoint; + + /** + * Creates an instance of RunStepSharepointToolCall class. + * + * @param id the id value to set. + * @param sharePoint the sharePoint value to set. + */ + @Generated + private RunStepSharepointToolCall(String id, Map sharePoint) { + super(id); + this.sharePoint = sharePoint; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the sharePoint property: Reserved for future use. + * + * @return the sharePoint value. + */ + @Generated + public Map getSharePoint() { + return this.sharePoint; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", getId()); + jsonWriter.writeMapField("sharepoint_grounding", this.sharePoint, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepSharepointToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepSharepointToolCall if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepSharepointToolCall. + */ + @Generated + public static RunStepSharepointToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + Map sharePoint = null; + String type = "sharepoint_grounding"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("sharepoint_grounding".equals(fieldName)) { + sharePoint = reader.readMap(reader1 -> reader1.getString()); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepSharepointToolCall deserializedRunStepSharepointToolCall + = new RunStepSharepointToolCall(id, sharePoint); + deserializedRunStepSharepointToolCall.type = type; + return deserializedRunStepSharepointToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepStatus.java new file mode 100644 index 000000000000..dd3cfcdfae24 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepStatus.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Possible values for the status of a run step. + */ +public final class RunStepStatus extends ExpandableStringEnum { + + /** + * Represents a run step still in progress. + */ + @Generated + public static final RunStepStatus IN_PROGRESS = fromString("in_progress"); + + /** + * Represents a run step that was cancelled. + */ + @Generated + public static final RunStepStatus CANCELLED = fromString("cancelled"); + + /** + * Represents a run step that failed. + */ + @Generated + public static final RunStepStatus FAILED = fromString("failed"); + + /** + * Represents a run step that successfully completed. + */ + @Generated + public static final RunStepStatus COMPLETED = fromString("completed"); + + /** + * Represents a run step that expired before otherwise finishing. + */ + @Generated + public static final RunStepStatus EXPIRED = fromString("expired"); + + /** + * Creates a new instance of RunStepStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public RunStepStatus() { + } + + /** + * Creates or finds a RunStepStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding RunStepStatus. + */ + @Generated + public static RunStepStatus fromString(String name) { + return fromString(name, RunStepStatus.class); + } + + /** + * Gets known RunStepStatus values. + * + * @return known RunStepStatus values. + */ + @Generated + public static Collection values() { + return values(RunStepStatus.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepStreamEvent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepStreamEvent.java new file mode 100644 index 000000000000..574bfcac02c7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepStreamEvent.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Run step operation related streaming events. + */ +public final class RunStepStreamEvent extends ExpandableStringEnum { + + /** + * Event sent when a new thread run step is created. The data of this event is of type RunStep. + */ + @Generated + public static final RunStepStreamEvent THREAD_RUN_STEP_CREATED = fromString("thread.run.step.created"); + + /** + * Event sent when a run step moves to `in_progress` status. The data of this event is of type RunStep. + */ + @Generated + public static final RunStepStreamEvent THREAD_RUN_STEP_IN_PROGRESS = fromString("thread.run.step.in_progress"); + + /** + * Event sent when a run step is being streamed. The data of this event is of type RunStepDeltaChunk. + */ + @Generated + public static final RunStepStreamEvent THREAD_RUN_STEP_DELTA = fromString("thread.run.step.delta"); + + /** + * Event sent when a run step is completed. The data of this event is of type RunStep. + */ + @Generated + public static final RunStepStreamEvent THREAD_RUN_STEP_COMPLETED = fromString("thread.run.step.completed"); + + /** + * Event sent when a run step fails. The data of this event is of type RunStep. + */ + @Generated + public static final RunStepStreamEvent THREAD_RUN_STEP_FAILED = fromString("thread.run.step.failed"); + + /** + * Event sent when a run step is cancelled. The data of this event is of type RunStep. + */ + @Generated + public static final RunStepStreamEvent THREAD_RUN_STEP_CANCELLED = fromString("thread.run.step.cancelled"); + + /** + * Event sent when a run step is expired. The data of this event is of type RunStep. + */ + @Generated + public static final RunStepStreamEvent THREAD_RUN_STEP_EXPIRED = fromString("thread.run.step.expired"); + + /** + * Creates a new instance of RunStepStreamEvent value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public RunStepStreamEvent() { + } + + /** + * Creates or finds a RunStepStreamEvent from its string representation. + * + * @param name a name to look for. + * @return the corresponding RunStepStreamEvent. + */ + @Generated + public static RunStepStreamEvent fromString(String name) { + return fromString(name, RunStepStreamEvent.class); + } + + /** + * Gets known RunStepStreamEvent values. + * + * @return known RunStepStreamEvent values. + */ + @Generated + public static Collection values() { + return values(RunStepStreamEvent.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCall.java new file mode 100644 index 000000000000..1ef544d74373 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCall.java @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An abstract representation of a detailed tool call as recorded within a run step for an existing run. + */ +@Immutable +public class RunStepToolCall implements JsonSerializable { + + /* + * The object type. + */ + @Generated + private String type = "RunStepToolCall"; + + /* + * The ID of the tool call. This ID must be referenced when you submit tool outputs. + */ + @Generated + private final String id; + + /** + * Creates an instance of RunStepToolCall class. + * + * @param id the id value to set. + */ + @Generated + protected RunStepToolCall(String id) { + this.id = id; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * Get the id property: The ID of the tool call. This ID must be referenced when you submit tool outputs. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepToolCall from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepToolCall if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepToolCall. + */ + @Generated + public static RunStepToolCall fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("code_interpreter".equals(discriminatorValue)) { + return RunStepCodeInterpreterToolCall.fromJson(readerToUse.reset()); + } else if ("file_search".equals(discriminatorValue)) { + return RunStepFileSearchToolCall.fromJson(readerToUse.reset()); + } else if ("bing_grounding".equals(discriminatorValue)) { + return RunStepBingGroundingToolCall.fromJson(readerToUse.reset()); + } else if ("azure_ai_search".equals(discriminatorValue)) { + return RunStepAzureAISearchToolCall.fromJson(readerToUse.reset()); + } else if ("sharepoint_grounding".equals(discriminatorValue)) { + return RunStepSharepointToolCall.fromJson(readerToUse.reset()); + } else if ("fabric_dataagent".equals(discriminatorValue)) { + return RunStepMicrosoftFabricToolCall.fromJson(readerToUse.reset()); + } else if ("bing_custom_search".equals(discriminatorValue)) { + return RunStepBingCustomSearchToolCall.fromJson(readerToUse.reset()); + } else if ("function".equals(discriminatorValue)) { + return RunStepFunctionToolCall.fromJson(readerToUse.reset()); + } else if ("openapi".equals(discriminatorValue)) { + return RunStepOpenApiToolCall.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static RunStepToolCall fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String type = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + RunStepToolCall deserializedRunStepToolCall = new RunStepToolCall(id); + deserializedRunStepToolCall.type = type; + return deserializedRunStepToolCall; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCallDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCallDetails.java new file mode 100644 index 000000000000..c6a071c4fa99 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCallDetails.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The detailed information associated with a run step calling tools. + */ +@Immutable +public final class RunStepToolCallDetails extends RunStepDetails { + + /* + * The object type. + */ + @Generated + private RunStepType type = RunStepType.TOOL_CALLS; + + /* + * A list of tool call details for this run step. + */ + @Generated + private final List toolCalls; + + /** + * Creates an instance of RunStepToolCallDetails class. + * + * @param toolCalls the toolCalls value to set. + */ + @Generated + private RunStepToolCallDetails(List toolCalls) { + this.toolCalls = toolCalls; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public RunStepType getType() { + return this.type; + } + + /** + * Get the toolCalls property: A list of tool call details for this run step. + * + * @return the toolCalls value. + */ + @Generated + public List getToolCalls() { + return this.toolCalls; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("tool_calls", this.toolCalls, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RunStepToolCallDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RunStepToolCallDetails if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the RunStepToolCallDetails. + */ + @Generated + public static RunStepToolCallDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List toolCalls = null; + RunStepType type = RunStepType.TOOL_CALLS; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("tool_calls".equals(fieldName)) { + toolCalls = reader.readArray(reader1 -> RunStepToolCall.fromJson(reader1)); + } else if ("type".equals(fieldName)) { + type = RunStepType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + RunStepToolCallDetails deserializedRunStepToolCallDetails = new RunStepToolCallDetails(toolCalls); + deserializedRunStepToolCallDetails.type = type; + return deserializedRunStepToolCallDetails; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepType.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepType.java new file mode 100644 index 000000000000..db1a268dd951 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepType.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The possible types of run steps. + */ +public final class RunStepType extends ExpandableStringEnum { + + /** + * Represents a run step to create a message. + */ + @Generated + public static final RunStepType MESSAGE_CREATION = fromString("message_creation"); + + /** + * Represents a run step that calls tools. + */ + @Generated + public static final RunStepType TOOL_CALLS = fromString("tool_calls"); + + /** + * Creates a new instance of RunStepType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public RunStepType() { + } + + /** + * Creates or finds a RunStepType from its string representation. + * + * @param name a name to look for. + * @return the corresponding RunStepType. + */ + @Generated + public static RunStepType fromString(String name) { + return fromString(name, RunStepType.class); + } + + /** + * Gets known RunStepType values. + * + * @return known RunStepType values. + */ + @Generated + public static Collection values() { + return values(RunStepType.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStreamEvent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStreamEvent.java new file mode 100644 index 000000000000..a6acb0eaea0d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStreamEvent.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Run operation related streaming events. + */ +public final class RunStreamEvent extends ExpandableStringEnum { + + /** + * Event sent when a new run is created. The data of this event is of type ThreadRun. + */ + @Generated + public static final RunStreamEvent THREAD_RUN_CREATED = fromString("thread.run.created"); + + /** + * Event sent when a run moves to `queued` status. The data of this event is of type ThreadRun. + */ + @Generated + public static final RunStreamEvent THREAD_RUN_QUEUED = fromString("thread.run.queued"); + + /** + * Event sent when a run moves to `in_progress` status. The data of this event is of type ThreadRun. + */ + @Generated + public static final RunStreamEvent THREAD_RUN_IN_PROGRESS = fromString("thread.run.in_progress"); + + /** + * Event sent when a run moves to `requires_action` status. The data of this event is of type ThreadRun. + */ + @Generated + public static final RunStreamEvent THREAD_RUN_REQUIRES_ACTION = fromString("thread.run.requires_action"); + + /** + * Event sent when a run is completed. The data of this event is of type ThreadRun. + */ + @Generated + public static final RunStreamEvent THREAD_RUN_COMPLETED = fromString("thread.run.completed"); + + /** + * Event sent when a run ends incomplete. The data of this event is of type ThreadRun. + */ + @Generated + public static final RunStreamEvent THREAD_RUN_INCOMPLETE = fromString("thread.run.incomplete"); + + /** + * Event sent when a run fails. The data of this event is of type ThreadRun. + */ + @Generated + public static final RunStreamEvent THREAD_RUN_FAILED = fromString("thread.run.failed"); + + /** + * Event sent when a run moves to `cancelling` status. The data of this event is of type ThreadRun. + */ + @Generated + public static final RunStreamEvent THREAD_RUN_CANCELLING = fromString("thread.run.cancelling"); + + /** + * Event sent when a run is cancelled. The data of this event is of type ThreadRun. + */ + @Generated + public static final RunStreamEvent THREAD_RUN_CANCELLED = fromString("thread.run.cancelled"); + + /** + * Event sent when a run is expired. The data of this event is of type ThreadRun. + */ + @Generated + public static final RunStreamEvent THREAD_RUN_EXPIRED = fromString("thread.run.expired"); + + /** + * Creates a new instance of RunStreamEvent value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public RunStreamEvent() { + } + + /** + * Creates or finds a RunStreamEvent from its string representation. + * + * @param name a name to look for. + * @return the corresponding RunStreamEvent. + */ + @Generated + public static RunStreamEvent fromString(String name) { + return fromString(name, RunStreamEvent.class); + } + + /** + * Gets known RunStreamEvent values. + * + * @return known RunStreamEvent values. + */ + @Generated + public static Collection values() { + return values(RunStreamEvent.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SharepointToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SharepointToolDefinition.java new file mode 100644 index 000000000000..fe7ee6e5cd7a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SharepointToolDefinition.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The input definition information for a sharepoint tool as used to configure an agent. + */ +@Immutable +public final class SharepointToolDefinition extends ToolDefinition { + + /* + * The object type. + */ + @Generated + private String type = "sharepoint_grounding"; + + /* + * The list of connections used by the SharePoint tool. + */ + @Generated + private final ToolConnectionList sharepointGrounding; + + /** + * Creates an instance of SharepointToolDefinition class. + * + * @param sharepointGrounding the sharepointGrounding value to set. + */ + @Generated + public SharepointToolDefinition(ToolConnectionList sharepointGrounding) { + this.sharepointGrounding = sharepointGrounding; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the sharepointGrounding property: The list of connections used by the SharePoint tool. + * + * @return the sharepointGrounding value. + */ + @Generated + public ToolConnectionList getSharepointGrounding() { + return this.sharepointGrounding; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("sharepoint_grounding", this.sharepointGrounding); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SharepointToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SharepointToolDefinition if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SharepointToolDefinition. + */ + @Generated + public static SharepointToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ToolConnectionList sharepointGrounding = null; + String type = "sharepoint_grounding"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("sharepoint_grounding".equals(fieldName)) { + sharepointGrounding = ToolConnectionList.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + SharepointToolDefinition deserializedSharepointToolDefinition + = new SharepointToolDefinition(sharepointGrounding); + deserializedSharepointToolDefinition.type = type; + return deserializedSharepointToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SubmitToolOutputsAction.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SubmitToolOutputsAction.java new file mode 100644 index 000000000000..2a3ccbda8faa --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SubmitToolOutputsAction.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The details for required tool calls that must be submitted for an agent thread run to continue. + */ +@Immutable +public final class SubmitToolOutputsAction extends RequiredAction { + + /* + * The object type. + */ + @Generated + private String type = "submit_tool_outputs"; + + /* + * The details describing tools that should be called to submit tool outputs. + */ + @Generated + private final SubmitToolOutputsDetails submitToolOutputs; + + /** + * Creates an instance of SubmitToolOutputsAction class. + * + * @param submitToolOutputs the submitToolOutputs value to set. + */ + @Generated + private SubmitToolOutputsAction(SubmitToolOutputsDetails submitToolOutputs) { + this.submitToolOutputs = submitToolOutputs; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public String getType() { + return this.type; + } + + /** + * Get the submitToolOutputs property: The details describing tools that should be called to submit tool outputs. + * + * @return the submitToolOutputs value. + */ + @Generated + public SubmitToolOutputsDetails getSubmitToolOutputs() { + return this.submitToolOutputs; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("submit_tool_outputs", this.submitToolOutputs); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SubmitToolOutputsAction from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SubmitToolOutputsAction if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SubmitToolOutputsAction. + */ + @Generated + public static SubmitToolOutputsAction fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SubmitToolOutputsDetails submitToolOutputs = null; + String type = "submit_tool_outputs"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("submit_tool_outputs".equals(fieldName)) { + submitToolOutputs = SubmitToolOutputsDetails.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = reader.getString(); + } else { + reader.skipChildren(); + } + } + SubmitToolOutputsAction deserializedSubmitToolOutputsAction + = new SubmitToolOutputsAction(submitToolOutputs); + deserializedSubmitToolOutputsAction.type = type; + return deserializedSubmitToolOutputsAction; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SubmitToolOutputsDetails.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SubmitToolOutputsDetails.java new file mode 100644 index 000000000000..20f83ab36398 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SubmitToolOutputsDetails.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The details describing tools that should be called to submit tool outputs. + */ +@Immutable +public final class SubmitToolOutputsDetails implements JsonSerializable { + + /* + * The list of tool calls that must be resolved for the agent thread run to continue. + */ + @Generated + private final List toolCalls; + + /** + * Creates an instance of SubmitToolOutputsDetails class. + * + * @param toolCalls the toolCalls value to set. + */ + @Generated + private SubmitToolOutputsDetails(List toolCalls) { + this.toolCalls = toolCalls; + } + + /** + * Get the toolCalls property: The list of tool calls that must be resolved for the agent thread run to continue. + * + * @return the toolCalls value. + */ + @Generated + public List getToolCalls() { + return this.toolCalls; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("tool_calls", this.toolCalls, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SubmitToolOutputsDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SubmitToolOutputsDetails if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SubmitToolOutputsDetails. + */ + @Generated + public static SubmitToolOutputsDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List toolCalls = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("tool_calls".equals(fieldName)) { + toolCalls = reader.readArray(reader1 -> RequiredToolCall.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new SubmitToolOutputsDetails(toolCalls); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadDeletionStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadDeletionStatus.java new file mode 100644 index 000000000000..874964523247 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadDeletionStatus.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The status of a thread deletion operation. + */ +@Immutable +public final class ThreadDeletionStatus implements JsonSerializable { + + /* + * The ID of the resource specified for deletion. + */ + @Generated + private final String id; + + /* + * A value indicating whether deletion was successful. + */ + @Generated + private final boolean deleted; + + /* + * The object type, which is always 'thread.deleted'. + */ + @Generated + private final String object = "thread.deleted"; + + /** + * Creates an instance of ThreadDeletionStatus class. + * + * @param id the id value to set. + * @param deleted the deleted value to set. + */ + @Generated + private ThreadDeletionStatus(String id, boolean deleted) { + this.id = id; + this.deleted = deleted; + } + + /** + * Get the id property: The ID of the resource specified for deletion. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the deleted property: A value indicating whether deletion was successful. + * + * @return the deleted value. + */ + @Generated + public boolean isDeleted() { + return this.deleted; + } + + /** + * Get the object property: The object type, which is always 'thread.deleted'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeBooleanField("deleted", this.deleted); + jsonWriter.writeStringField("object", this.object); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ThreadDeletionStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ThreadDeletionStatus if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ThreadDeletionStatus. + */ + @Generated + public static ThreadDeletionStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + boolean deleted = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("deleted".equals(fieldName)) { + deleted = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new ThreadDeletionStatus(id, deleted); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadMessage.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadMessage.java new file mode 100644 index 000000000000..ec5bca136312 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadMessage.java @@ -0,0 +1,402 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; +import java.util.Map; + +/** + * A single, existing message within an agent thread. + */ +@Immutable +public final class ThreadMessage implements JsonSerializable { + + /* + * The identifier, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The object type, which is always 'thread.message'. + */ + @Generated + private final String object = "thread.message"; + + /* + * The Unix timestamp, in seconds, representing when this object was created. + */ + @Generated + private final long createdAt; + + /* + * The ID of the thread that this message belongs to. + */ + @Generated + private final String threadId; + + /* + * The status of the message. + */ + @Generated + private final MessageStatus status; + + /* + * On an incomplete message, details about why the message is incomplete. + */ + @Generated + private final MessageIncompleteDetails incompleteDetails; + + /* + * The Unix timestamp (in seconds) for when the message was completed. + */ + @Generated + private final Long completedAt; + + /* + * The Unix timestamp (in seconds) for when the message was marked as incomplete. + */ + @Generated + private final Long incompleteAt; + + /* + * The role associated with the agent thread message. + */ + @Generated + private final MessageRole role; + + /* + * The list of content items associated with the agent thread message. + */ + @Generated + private final List content; + + /* + * If applicable, the ID of the agent that authored this message. + */ + @Generated + private final String assistantId; + + /* + * If applicable, the ID of the run associated with the authoring of this message. + */ + @Generated + private final String runId; + + /* + * A list of files attached to the message, and the tools they were added to. + */ + @Generated + private final List attachments; + + /* + * 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. + */ + @Generated + private final Map metadata; + + /** + * Creates an instance of ThreadMessage class. + * + * @param id the id value to set. + * @param createdAt the createdAt value to set. + * @param threadId the threadId value to set. + * @param status the status value to set. + * @param incompleteDetails the incompleteDetails value to set. + * @param completedAt the completedAt value to set. + * @param incompleteAt the incompleteAt value to set. + * @param role the role value to set. + * @param content the content value to set. + * @param assistantId the assistantId value to set. + * @param runId the runId value to set. + * @param attachments the attachments value to set. + * @param metadata the metadata value to set. + */ + @Generated + private ThreadMessage(String id, OffsetDateTime createdAt, String threadId, MessageStatus status, + MessageIncompleteDetails incompleteDetails, OffsetDateTime completedAt, OffsetDateTime incompleteAt, + MessageRole role, List content, String assistantId, String runId, + List attachments, Map metadata) { + this.id = id; + if (createdAt == null) { + this.createdAt = 0L; + } else { + this.createdAt = createdAt.toEpochSecond(); + } + this.threadId = threadId; + this.status = status; + this.incompleteDetails = incompleteDetails; + if (completedAt == null) { + this.completedAt = null; + } else { + this.completedAt = completedAt.toEpochSecond(); + } + if (incompleteAt == null) { + this.incompleteAt = null; + } else { + this.incompleteAt = incompleteAt.toEpochSecond(); + } + this.role = role; + this.content = content; + this.assistantId = assistantId; + this.runId = runId; + this.attachments = attachments; + this.metadata = metadata; + } + + /** + * Get the id property: The identifier, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the object property: The object type, which is always 'thread.message'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the createdAt property: The Unix timestamp, in seconds, representing when this object was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC); + } + + /** + * Get the threadId property: The ID of the thread that this message belongs to. + * + * @return the threadId value. + */ + @Generated + public String getThreadId() { + return this.threadId; + } + + /** + * Get the status property: The status of the message. + * + * @return the status value. + */ + @Generated + public MessageStatus getStatus() { + return this.status; + } + + /** + * Get the incompleteDetails property: On an incomplete message, details about why the message is incomplete. + * + * @return the incompleteDetails value. + */ + @Generated + public MessageIncompleteDetails getIncompleteDetails() { + return this.incompleteDetails; + } + + /** + * Get the completedAt property: The Unix timestamp (in seconds) for when the message was completed. + * + * @return the completedAt value. + */ + @Generated + public OffsetDateTime getCompletedAt() { + if (this.completedAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.completedAt), ZoneOffset.UTC); + } + + /** + * Get the incompleteAt property: The Unix timestamp (in seconds) for when the message was marked as incomplete. + * + * @return the incompleteAt value. + */ + @Generated + public OffsetDateTime getIncompleteAt() { + if (this.incompleteAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.incompleteAt), ZoneOffset.UTC); + } + + /** + * Get the role property: The role associated with the agent thread message. + * + * @return the role value. + */ + @Generated + public MessageRole getRole() { + return this.role; + } + + /** + * Get the content property: The list of content items associated with the agent thread message. + * + * @return the content value. + */ + @Generated + public List getContent() { + return this.content; + } + + /** + * Get the assistantId property: If applicable, the ID of the agent that authored this message. + * + * @return the assistantId value. + */ + @Generated + public String getAssistantId() { + return this.assistantId; + } + + /** + * Get the runId property: If applicable, the ID of the run associated with the authoring of this message. + * + * @return the runId value. + */ + @Generated + public String getRunId() { + return this.runId; + } + + /** + * Get the attachments property: A list of files attached to the message, and the tools they were added to. + * + * @return the attachments value. + */ + @Generated + public List getAttachments() { + return this.attachments; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeLongField("created_at", this.createdAt); + jsonWriter.writeStringField("thread_id", this.threadId); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("incomplete_details", this.incompleteDetails); + jsonWriter.writeNumberField("completed_at", this.completedAt); + jsonWriter.writeNumberField("incomplete_at", this.incompleteAt); + jsonWriter.writeStringField("role", this.role == null ? null : this.role.toString()); + jsonWriter.writeArrayField("content", this.content, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("assistant_id", this.assistantId); + jsonWriter.writeStringField("run_id", this.runId); + jsonWriter.writeArrayField("attachments", this.attachments, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ThreadMessage from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ThreadMessage if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ThreadMessage. + */ + @Generated + public static ThreadMessage fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OffsetDateTime createdAt = null; + String threadId = null; + MessageStatus status = null; + MessageIncompleteDetails incompleteDetails = null; + OffsetDateTime completedAt = null; + OffsetDateTime incompleteAt = null; + MessageRole role = null; + List content = null; + String assistantId = null; + String runId = null; + List attachments = null; + Map metadata = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("created_at".equals(fieldName)) { + createdAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader.getLong()), ZoneOffset.UTC); + } else if ("thread_id".equals(fieldName)) { + threadId = reader.getString(); + } else if ("status".equals(fieldName)) { + status = MessageStatus.fromString(reader.getString()); + } else if ("incomplete_details".equals(fieldName)) { + incompleteDetails = MessageIncompleteDetails.fromJson(reader); + } else if ("completed_at".equals(fieldName)) { + Long completedAtHolder = reader.getNullable(JsonReader::getLong); + if (completedAtHolder != null) { + completedAt + = OffsetDateTime.ofInstant(Instant.ofEpochSecond(completedAtHolder), ZoneOffset.UTC); + } + } else if ("incomplete_at".equals(fieldName)) { + Long incompleteAtHolder = reader.getNullable(JsonReader::getLong); + if (incompleteAtHolder != null) { + incompleteAt + = OffsetDateTime.ofInstant(Instant.ofEpochSecond(incompleteAtHolder), ZoneOffset.UTC); + } + } else if ("role".equals(fieldName)) { + role = MessageRole.fromString(reader.getString()); + } else if ("content".equals(fieldName)) { + content = reader.readArray(reader1 -> MessageContent.fromJson(reader1)); + } else if ("assistant_id".equals(fieldName)) { + assistantId = reader.getString(); + } else if ("run_id".equals(fieldName)) { + runId = reader.getString(); + } else if ("attachments".equals(fieldName)) { + attachments = reader.readArray(reader1 -> MessageAttachment.fromJson(reader1)); + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new ThreadMessage(id, createdAt, threadId, status, incompleteDetails, completedAt, incompleteAt, + role, content, assistantId, runId, attachments, metadata); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadMessageOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadMessageOptions.java new file mode 100644 index 000000000000..cd9618d21286 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadMessageOptions.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * A single message within an agent thread, + * as provided during that thread's creation for its initial state. + */ +@Fluent +public final class ThreadMessageOptions implements JsonSerializable { + + /* + * The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + */ + @Generated + private final MessageRole role; + + /* + * The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + */ + @Generated + private final BinaryData content; + + /* + * A list of files attached to the message, and the tools they should be added to. + */ + @Generated + private List attachments; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of ThreadMessageOptions class. + * + * @param role the role value to set. + * @param content the content value to set. + */ + @Generated + public ThreadMessageOptions(MessageRole role, BinaryData content) { + this.role = role; + this.content = content; + } + + /** + * Get the role property: The role of the entity that is creating the message. Allowed values include: + * `user`, which indicates the message is sent by an actual user (and should be + * used in most cases to represent user-generated messages), and `assistant`, + * which indicates the message is generated by the agent (use this value to insert + * messages from the agent into the conversation). + * + * @return the role value. + */ + @Generated + public MessageRole getRole() { + return this.role; + } + + /** + * Get the content property: The content of the initial message. This may be a basic string (if you only + * need text) or an array of typed content blocks (for example, text, image_file, + * image_url, and so on). + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the attachments property: A list of files attached to the message, and the tools they should be added to. + * + * @return the attachments value. + */ + @Generated + public List getAttachments() { + return this.attachments; + } + + /** + * Set the attachments property: A list of files attached to the message, and the tools they should be added to. + * + * @param attachments the attachments value to set. + * @return the ThreadMessageOptions object itself. + */ + @Generated + public ThreadMessageOptions setAttachments(List attachments) { + this.attachments = attachments; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the ThreadMessageOptions object itself. + */ + @Generated + public ThreadMessageOptions setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("role", this.role == null ? null : this.role.toString()); + jsonWriter.writeFieldName("content"); + this.content.writeTo(jsonWriter); + jsonWriter.writeArrayField("attachments", this.attachments, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ThreadMessageOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ThreadMessageOptions if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ThreadMessageOptions. + */ + @Generated + public static ThreadMessageOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MessageRole role = null; + BinaryData content = null; + List attachments = null; + Map metadata = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("role".equals(fieldName)) { + role = MessageRole.fromString(reader.getString()); + } else if ("content".equals(fieldName)) { + content = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("attachments".equals(fieldName)) { + attachments = reader.readArray(reader1 -> MessageAttachment.fromJson(reader1)); + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + ThreadMessageOptions deserializedThreadMessageOptions = new ThreadMessageOptions(role, content); + deserializedThreadMessageOptions.attachments = attachments; + deserializedThreadMessageOptions.metadata = metadata; + return deserializedThreadMessageOptions; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadRun.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadRun.java new file mode 100644 index 000000000000..5489d72d243b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadRun.java @@ -0,0 +1,753 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.BinaryData; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; +import java.util.Map; + +/** + * Data representing a single evaluation run of an agent thread. + */ +@Immutable +public final class ThreadRun implements JsonSerializable { + + /* + * The identifier, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The object type, which is always 'thread.run'. + */ + @Generated + private final String object = "thread.run"; + + /* + * The ID of the thread associated with this run. + */ + @Generated + private final String threadId; + + /* + * The ID of the agent associated with the thread this run was performed against. + */ + @Generated + private final String assistantId; + + /* + * The status of the agent thread run. + */ + @Generated + private final RunStatus status; + + /* + * The details of the action required for the agent thread run to continue. + */ + @Generated + private RequiredAction requiredAction; + + /* + * The last error, if any, encountered by this agent thread run. + */ + @Generated + private final RunError lastError; + + /* + * The ID of the model to use. + */ + @Generated + private final String model; + + /* + * The overridden system instructions used for this agent thread run. + */ + @Generated + private final String instructions; + + /* + * The overridden enabled tools used for this agent thread run. + */ + @Generated + private final List tools; + + /* + * The Unix timestamp, in seconds, representing when this object was created. + */ + @Generated + private final long createdAt; + + /* + * The Unix timestamp, in seconds, representing when this item expires. + */ + @Generated + private final Long expiresAt; + + /* + * The Unix timestamp, in seconds, representing when this item was started. + */ + @Generated + private final Long startedAt; + + /* + * The Unix timestamp, in seconds, representing when this completed. + */ + @Generated + private final Long completedAt; + + /* + * The Unix timestamp, in seconds, representing when this was cancelled. + */ + @Generated + private final Long cancelledAt; + + /* + * The Unix timestamp, in seconds, representing when this failed. + */ + @Generated + private final Long failedAt; + + /* + * Details on why the run is incomplete. Will be `null` if the run is not incomplete. + */ + @Generated + private final IncompleteRunDetails incompleteDetails; + + /* + * Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. + * `in_progress`, `queued`, etc.). + */ + @Generated + private final RunCompletionUsage usage; + + /* + * The sampling temperature used for this run. If not set, defaults to 1. + */ + @Generated + private Double temperature; + + /* + * The nucleus sampling value used for this run. If not set, defaults to 1. + */ + @Generated + private Double topP; + + /* + * The maximum number of prompt tokens specified to have been used over the course of the run. + */ + @Generated + private final Integer maxPromptTokens; + + /* + * The maximum number of completion tokens specified to have been used over the course of the run. + */ + @Generated + private final Integer maxCompletionTokens; + + /* + * The strategy to use for dropping messages as the context windows moves forward. + */ + @Generated + private final TruncationObject truncationStrategy; + + /* + * Controls whether or not and which tool is called by the model. + */ + @Generated + private final BinaryData toolChoice; + + /* + * The response format of the tool calls used in this run. + */ + @Generated + private final BinaryData responseFormat; + + /* + * 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. + */ + @Generated + private final Map metadata; + + /* + * Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis + */ + @Generated + private UpdateToolResourcesOptions toolResources; + + /* + * Determines if tools can be executed in parallel within the run. + */ + @Generated + private final boolean parallelToolCalls; + + /** + * Creates an instance of ThreadRun class. + * + * @param id the id value to set. + * @param threadId the threadId value to set. + * @param assistantId the assistantId value to set. + * @param status the status value to set. + * @param lastError the lastError value to set. + * @param model the model value to set. + * @param instructions the instructions value to set. + * @param tools the tools value to set. + * @param createdAt the createdAt value to set. + * @param expiresAt the expiresAt value to set. + * @param startedAt the startedAt value to set. + * @param completedAt the completedAt value to set. + * @param cancelledAt the cancelledAt value to set. + * @param failedAt the failedAt value to set. + * @param incompleteDetails the incompleteDetails value to set. + * @param usage the usage value to set. + * @param maxPromptTokens the maxPromptTokens value to set. + * @param maxCompletionTokens the maxCompletionTokens value to set. + * @param truncationStrategy the truncationStrategy value to set. + * @param toolChoice the toolChoice value to set. + * @param responseFormat the responseFormat value to set. + * @param metadata the metadata value to set. + * @param parallelToolCalls the parallelToolCalls value to set. + */ + @Generated + private ThreadRun(String id, String threadId, String assistantId, RunStatus status, RunError lastError, + String model, String instructions, List tools, OffsetDateTime createdAt, + OffsetDateTime expiresAt, OffsetDateTime startedAt, OffsetDateTime completedAt, OffsetDateTime cancelledAt, + OffsetDateTime failedAt, IncompleteRunDetails incompleteDetails, RunCompletionUsage usage, + Integer maxPromptTokens, Integer maxCompletionTokens, TruncationObject truncationStrategy, + BinaryData toolChoice, BinaryData responseFormat, Map metadata, boolean parallelToolCalls) { + this.id = id; + this.threadId = threadId; + this.assistantId = assistantId; + this.status = status; + this.lastError = lastError; + this.model = model; + this.instructions = instructions; + this.tools = tools; + if (createdAt == null) { + this.createdAt = 0L; + } else { + this.createdAt = createdAt.toEpochSecond(); + } + if (expiresAt == null) { + this.expiresAt = null; + } else { + this.expiresAt = expiresAt.toEpochSecond(); + } + if (startedAt == null) { + this.startedAt = null; + } else { + this.startedAt = startedAt.toEpochSecond(); + } + if (completedAt == null) { + this.completedAt = null; + } else { + this.completedAt = completedAt.toEpochSecond(); + } + if (cancelledAt == null) { + this.cancelledAt = null; + } else { + this.cancelledAt = cancelledAt.toEpochSecond(); + } + if (failedAt == null) { + this.failedAt = null; + } else { + this.failedAt = failedAt.toEpochSecond(); + } + this.incompleteDetails = incompleteDetails; + this.usage = usage; + this.maxPromptTokens = maxPromptTokens; + this.maxCompletionTokens = maxCompletionTokens; + this.truncationStrategy = truncationStrategy; + this.toolChoice = toolChoice; + this.responseFormat = responseFormat; + this.metadata = metadata; + this.parallelToolCalls = parallelToolCalls; + } + + /** + * Get the id property: The identifier, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the object property: The object type, which is always 'thread.run'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the threadId property: The ID of the thread associated with this run. + * + * @return the threadId value. + */ + @Generated + public String getThreadId() { + return this.threadId; + } + + /** + * Get the assistantId property: The ID of the agent associated with the thread this run was performed against. + * + * @return the assistantId value. + */ + @Generated + public String getAssistantId() { + return this.assistantId; + } + + /** + * Get the status property: The status of the agent thread run. + * + * @return the status value. + */ + @Generated + public RunStatus getStatus() { + return this.status; + } + + /** + * Get the requiredAction property: The details of the action required for the agent thread run to continue. + * + * @return the requiredAction value. + */ + @Generated + public RequiredAction getRequiredAction() { + return this.requiredAction; + } + + /** + * Get the lastError property: The last error, if any, encountered by this agent thread run. + * + * @return the lastError value. + */ + @Generated + public RunError getLastError() { + return this.lastError; + } + + /** + * Get the model property: The ID of the model to use. + * + * @return the model value. + */ + @Generated + public String getModel() { + return this.model; + } + + /** + * Get the instructions property: The overridden system instructions used for this agent thread run. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Get the tools property: The overridden enabled tools used for this agent thread run. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * Get the createdAt property: The Unix timestamp, in seconds, representing when this object was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC); + } + + /** + * Get the expiresAt property: The Unix timestamp, in seconds, representing when this item expires. + * + * @return the expiresAt value. + */ + @Generated + public OffsetDateTime getExpiresAt() { + if (this.expiresAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.expiresAt), ZoneOffset.UTC); + } + + /** + * Get the startedAt property: The Unix timestamp, in seconds, representing when this item was started. + * + * @return the startedAt value. + */ + @Generated + public OffsetDateTime getStartedAt() { + if (this.startedAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.startedAt), ZoneOffset.UTC); + } + + /** + * Get the completedAt property: The Unix timestamp, in seconds, representing when this completed. + * + * @return the completedAt value. + */ + @Generated + public OffsetDateTime getCompletedAt() { + if (this.completedAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.completedAt), ZoneOffset.UTC); + } + + /** + * Get the cancelledAt property: The Unix timestamp, in seconds, representing when this was cancelled. + * + * @return the cancelledAt value. + */ + @Generated + public OffsetDateTime getCancelledAt() { + if (this.cancelledAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.cancelledAt), ZoneOffset.UTC); + } + + /** + * Get the failedAt property: The Unix timestamp, in seconds, representing when this failed. + * + * @return the failedAt value. + */ + @Generated + public OffsetDateTime getFailedAt() { + if (this.failedAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.failedAt), ZoneOffset.UTC); + } + + /** + * Get the incompleteDetails property: Details on why the run is incomplete. Will be `null` if the run is not + * incomplete. + * + * @return the incompleteDetails value. + */ + @Generated + public IncompleteRunDetails getIncompleteDetails() { + return this.incompleteDetails; + } + + /** + * Get the usage property: Usage statistics related to the run. This value will be `null` if the run is not in a + * terminal state (i.e. `in_progress`, `queued`, etc.). + * + * @return the usage value. + */ + @Generated + public RunCompletionUsage getUsage() { + return this.usage; + } + + /** + * Get the temperature property: The sampling temperature used for this run. If not set, defaults to 1. + * + * @return the temperature value. + */ + @Generated + public Double getTemperature() { + return this.temperature; + } + + /** + * Get the topP property: The nucleus sampling value used for this run. If not set, defaults to 1. + * + * @return the topP value. + */ + @Generated + public Double getTopP() { + return this.topP; + } + + /** + * Get the maxPromptTokens property: The maximum number of prompt tokens specified to have been used over the course + * of the run. + * + * @return the maxPromptTokens value. + */ + @Generated + public Integer getMaxPromptTokens() { + return this.maxPromptTokens; + } + + /** + * Get the maxCompletionTokens property: The maximum number of completion tokens specified to have been used over + * the course of the run. + * + * @return the maxCompletionTokens value. + */ + @Generated + public Integer getMaxCompletionTokens() { + return this.maxCompletionTokens; + } + + /** + * Get the truncationStrategy property: The strategy to use for dropping messages as the context windows moves + * forward. + * + * @return the truncationStrategy value. + */ + @Generated + public TruncationObject getTruncationStrategy() { + return this.truncationStrategy; + } + + /** + * Get the toolChoice property: Controls whether or not and which tool is called by the model. + * + * @return the toolChoice value. + */ + @Generated + public BinaryData getToolChoice() { + return this.toolChoice; + } + + /** + * Get the responseFormat property: The response format of the tool calls used in this run. + * + * @return the responseFormat value. + */ + @Generated + public BinaryData getResponseFormat() { + return this.responseFormat; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Get the toolResources property: Override the tools the agent can use for this run. This is useful for modifying + * the behavior on a per-run basis. + * + * @return the toolResources value. + */ + @Generated + public UpdateToolResourcesOptions getToolResources() { + return this.toolResources; + } + + /** + * Get the parallelToolCalls property: Determines if tools can be executed in parallel within the run. + * + * @return the parallelToolCalls value. + */ + @Generated + public boolean isParallelToolCalls() { + return this.parallelToolCalls; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeStringField("thread_id", this.threadId); + jsonWriter.writeStringField("assistant_id", this.assistantId); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("last_error", this.lastError); + jsonWriter.writeStringField("model", this.model); + jsonWriter.writeStringField("instructions", this.instructions); + jsonWriter.writeArrayField("tools", this.tools, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeLongField("created_at", this.createdAt); + jsonWriter.writeNumberField("expires_at", this.expiresAt); + jsonWriter.writeNumberField("started_at", this.startedAt); + jsonWriter.writeNumberField("completed_at", this.completedAt); + jsonWriter.writeNumberField("cancelled_at", this.cancelledAt); + jsonWriter.writeNumberField("failed_at", this.failedAt); + jsonWriter.writeJsonField("incomplete_details", this.incompleteDetails); + jsonWriter.writeJsonField("usage", this.usage); + jsonWriter.writeNumberField("max_prompt_tokens", this.maxPromptTokens); + jsonWriter.writeNumberField("max_completion_tokens", this.maxCompletionTokens); + jsonWriter.writeJsonField("truncation_strategy", this.truncationStrategy); + jsonWriter.writeFieldName("tool_choice"); + this.toolChoice.writeTo(jsonWriter); + jsonWriter.writeFieldName("response_format"); + this.responseFormat.writeTo(jsonWriter); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + jsonWriter.writeBooleanField("parallel_tool_calls", this.parallelToolCalls); + jsonWriter.writeJsonField("required_action", this.requiredAction); + jsonWriter.writeNumberField("temperature", this.temperature); + jsonWriter.writeNumberField("top_p", this.topP); + jsonWriter.writeJsonField("tool_resources", this.toolResources); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ThreadRun from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ThreadRun if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ThreadRun. + */ + @Generated + public static ThreadRun fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String threadId = null; + String assistantId = null; + RunStatus status = null; + RunError lastError = null; + String model = null; + String instructions = null; + List tools = null; + OffsetDateTime createdAt = null; + OffsetDateTime expiresAt = null; + OffsetDateTime startedAt = null; + OffsetDateTime completedAt = null; + OffsetDateTime cancelledAt = null; + OffsetDateTime failedAt = null; + IncompleteRunDetails incompleteDetails = null; + RunCompletionUsage usage = null; + Integer maxPromptTokens = null; + Integer maxCompletionTokens = null; + TruncationObject truncationStrategy = null; + BinaryData toolChoice = null; + BinaryData responseFormat = null; + Map metadata = null; + boolean parallelToolCalls = false; + RequiredAction requiredAction = null; + Double temperature = null; + Double topP = null; + UpdateToolResourcesOptions toolResources = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("thread_id".equals(fieldName)) { + threadId = reader.getString(); + } else if ("assistant_id".equals(fieldName)) { + assistantId = reader.getString(); + } else if ("status".equals(fieldName)) { + status = RunStatus.fromString(reader.getString()); + } else if ("last_error".equals(fieldName)) { + lastError = RunError.fromJson(reader); + } else if ("model".equals(fieldName)) { + model = reader.getString(); + } else if ("instructions".equals(fieldName)) { + instructions = reader.getString(); + } else if ("tools".equals(fieldName)) { + tools = reader.readArray(reader1 -> ToolDefinition.fromJson(reader1)); + } else if ("created_at".equals(fieldName)) { + createdAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader.getLong()), ZoneOffset.UTC); + } else if ("expires_at".equals(fieldName)) { + Long expiresAtHolder = reader.getNullable(JsonReader::getLong); + if (expiresAtHolder != null) { + expiresAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(expiresAtHolder), ZoneOffset.UTC); + } + } else if ("started_at".equals(fieldName)) { + Long startedAtHolder = reader.getNullable(JsonReader::getLong); + if (startedAtHolder != null) { + startedAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(startedAtHolder), ZoneOffset.UTC); + } + } else if ("completed_at".equals(fieldName)) { + Long completedAtHolder = reader.getNullable(JsonReader::getLong); + if (completedAtHolder != null) { + completedAt + = OffsetDateTime.ofInstant(Instant.ofEpochSecond(completedAtHolder), ZoneOffset.UTC); + } + } else if ("cancelled_at".equals(fieldName)) { + Long cancelledAtHolder = reader.getNullable(JsonReader::getLong); + if (cancelledAtHolder != null) { + cancelledAt + = OffsetDateTime.ofInstant(Instant.ofEpochSecond(cancelledAtHolder), ZoneOffset.UTC); + } + } else if ("failed_at".equals(fieldName)) { + Long failedAtHolder = reader.getNullable(JsonReader::getLong); + if (failedAtHolder != null) { + failedAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(failedAtHolder), ZoneOffset.UTC); + } + } else if ("incomplete_details".equals(fieldName)) { + incompleteDetails = IncompleteRunDetails.fromJson(reader); + } else if ("usage".equals(fieldName)) { + usage = RunCompletionUsage.fromJson(reader); + } else if ("max_prompt_tokens".equals(fieldName)) { + maxPromptTokens = reader.getNullable(JsonReader::getInt); + } else if ("max_completion_tokens".equals(fieldName)) { + maxCompletionTokens = reader.getNullable(JsonReader::getInt); + } else if ("truncation_strategy".equals(fieldName)) { + truncationStrategy = TruncationObject.fromJson(reader); + } else if ("tool_choice".equals(fieldName)) { + toolChoice + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("response_format".equals(fieldName)) { + responseFormat + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else if ("parallel_tool_calls".equals(fieldName)) { + parallelToolCalls = reader.getBoolean(); + } else if ("required_action".equals(fieldName)) { + requiredAction = RequiredAction.fromJson(reader); + } else if ("temperature".equals(fieldName)) { + temperature = reader.getNullable(JsonReader::getDouble); + } else if ("top_p".equals(fieldName)) { + topP = reader.getNullable(JsonReader::getDouble); + } else if ("tool_resources".equals(fieldName)) { + toolResources = UpdateToolResourcesOptions.fromJson(reader); + } else { + reader.skipChildren(); + } + } + ThreadRun deserializedThreadRun + = new ThreadRun(id, threadId, assistantId, status, lastError, model, instructions, tools, createdAt, + expiresAt, startedAt, completedAt, cancelledAt, failedAt, incompleteDetails, usage, maxPromptTokens, + maxCompletionTokens, truncationStrategy, toolChoice, responseFormat, metadata, parallelToolCalls); + deserializedThreadRun.requiredAction = requiredAction; + deserializedThreadRun.temperature = temperature; + deserializedThreadRun.topP = topP; + deserializedThreadRun.toolResources = toolResources; + return deserializedThreadRun; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadStreamEvent.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadStreamEvent.java new file mode 100644 index 000000000000..2bf2103b6f59 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ThreadStreamEvent.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Thread operation related streaming events. + */ +public final class ThreadStreamEvent extends ExpandableStringEnum { + + /** + * Event sent when a new thread is created. The data of this event is of type AgentThread. + */ + @Generated + public static final ThreadStreamEvent THREAD_CREATED = fromString("thread.created"); + + /** + * Creates a new instance of ThreadStreamEvent value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ThreadStreamEvent() { + } + + /** + * Creates or finds a ThreadStreamEvent from its string representation. + * + * @param name a name to look for. + * @return the corresponding ThreadStreamEvent. + */ + @Generated + public static ThreadStreamEvent fromString(String name) { + return fromString(name, ThreadStreamEvent.class); + } + + /** + * Gets known ThreadStreamEvent values. + * + * @return known ThreadStreamEvent values. + */ + @Generated + public static Collection values() { + return values(ThreadStreamEvent.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnection.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnection.java new file mode 100644 index 000000000000..9904b3ac4a30 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnection.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A connection resource. + */ +@Immutable +public final class ToolConnection implements JsonSerializable { + + /* + * A connection in a ToolConnectionList attached to this tool. + */ + @Generated + private final String connectionId; + + /** + * Creates an instance of ToolConnection class. + * + * @param connectionId the connectionId value to set. + */ + @Generated + public ToolConnection(String connectionId) { + this.connectionId = connectionId; + } + + /** + * Get the connectionId property: A connection in a ToolConnectionList attached to this tool. + * + * @return the connectionId value. + */ + @Generated + public String getConnectionId() { + return this.connectionId; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("connection_id", this.connectionId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ToolConnection from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ToolConnection if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ToolConnection. + */ + @Generated + public static ToolConnection fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String connectionId = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("connection_id".equals(fieldName)) { + connectionId = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ToolConnection(connectionId); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnectionList.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnectionList.java new file mode 100644 index 000000000000..8991a59d0d73 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnectionList.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * A set of connection resources currently used by either the `bing_grounding`, `fabric_dataagent`, or + * `sharepoint_grounding` tools. + */ +@Fluent +public final class ToolConnectionList implements JsonSerializable { + + /* + * The connections attached to this tool. There can be a maximum of 1 connection + * resource attached to the tool. + */ + @Generated + private List connectionList; + + /** + * Creates an instance of ToolConnectionList class. + */ + @Generated + public ToolConnectionList() { + } + + /** + * Get the connectionList property: The connections attached to this tool. There can be a maximum of 1 connection + * resource attached to the tool. + * + * @return the connectionList value. + */ + @Generated + public List getConnectionList() { + return this.connectionList; + } + + /** + * Set the connectionList property: The connections attached to this tool. There can be a maximum of 1 connection + * resource attached to the tool. + * + * @param connectionList the connectionList value to set. + * @return the ToolConnectionList object itself. + */ + @Generated + public ToolConnectionList setConnectionList(List connectionList) { + this.connectionList = connectionList; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("connections", this.connectionList, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ToolConnectionList from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ToolConnectionList if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ToolConnectionList. + */ + @Generated + public static ToolConnectionList fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ToolConnectionList deserializedToolConnectionList = new ToolConnectionList(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("connections".equals(fieldName)) { + List connectionList = reader.readArray(reader1 -> ToolConnection.fromJson(reader1)); + deserializedToolConnectionList.connectionList = connectionList; + } else { + reader.skipChildren(); + } + } + return deserializedToolConnectionList; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolDefinition.java new file mode 100644 index 000000000000..c174bced2ea0 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolDefinition.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An abstract representation of an input tool definition that an agent can use. + */ +@Immutable +public class ToolDefinition implements JsonSerializable { + + /* + * The object type. + */ + @Generated + private String type = "ToolDefinition"; + + /** + * Creates an instance of ToolDefinition class. + */ + @Generated + public ToolDefinition() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + public String getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ToolDefinition from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ToolDefinition if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ToolDefinition. + */ + @Generated + public static ToolDefinition fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("code_interpreter".equals(discriminatorValue)) { + return CodeInterpreterToolDefinition.fromJson(readerToUse.reset()); + } else if ("file_search".equals(discriminatorValue)) { + return FileSearchToolDefinition.fromJson(readerToUse.reset()); + } else if ("function".equals(discriminatorValue)) { + return FunctionToolDefinition.fromJson(readerToUse.reset()); + } else if ("bing_grounding".equals(discriminatorValue)) { + return BingGroundingToolDefinition.fromJson(readerToUse.reset()); + } else if ("fabric_dataagent".equals(discriminatorValue)) { + return MicrosoftFabricToolDefinition.fromJson(readerToUse.reset()); + } else if ("sharepoint_grounding".equals(discriminatorValue)) { + return SharepointToolDefinition.fromJson(readerToUse.reset()); + } else if ("azure_ai_search".equals(discriminatorValue)) { + return AzureAISearchToolDefinition.fromJson(readerToUse.reset()); + } else if ("openapi".equals(discriminatorValue)) { + return OpenApiToolDefinition.fromJson(readerToUse.reset()); + } else if ("bing_custom_search".equals(discriminatorValue)) { + return BingCustomSearchToolDefinition.fromJson(readerToUse.reset()); + } else if ("connected_agent".equals(discriminatorValue)) { + return ConnectedAgentToolDefinition.fromJson(readerToUse.reset()); + } else if ("azure_function".equals(discriminatorValue)) { + return AzureFunctionToolDefinition.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static ToolDefinition fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ToolDefinition deserializedToolDefinition = new ToolDefinition(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedToolDefinition.type = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedToolDefinition; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolOutput.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolOutput.java new file mode 100644 index 000000000000..5bd88b61631c --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolOutput.java @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The data provided during a tool outputs submission to resolve pending tool calls and allow the model to continue. + */ +@Fluent +public final class ToolOutput implements JsonSerializable { + + /* + * The ID of the tool call being resolved, as provided in the tool calls of a required action from a run. + */ + @Generated + private String toolCallId; + + /* + * The output from the tool to be submitted. + */ + @Generated + private String output; + + /** + * Creates an instance of ToolOutput class. + */ + @Generated + public ToolOutput() { + } + + /** + * Get the toolCallId property: The ID of the tool call being resolved, as provided in the tool calls of a required + * action from a run. + * + * @return the toolCallId value. + */ + @Generated + public String getToolCallId() { + return this.toolCallId; + } + + /** + * Set the toolCallId property: The ID of the tool call being resolved, as provided in the tool calls of a required + * action from a run. + * + * @param toolCallId the toolCallId value to set. + * @return the ToolOutput object itself. + */ + @Generated + public ToolOutput setToolCallId(String toolCallId) { + this.toolCallId = toolCallId; + return this; + } + + /** + * Get the output property: The output from the tool to be submitted. + * + * @return the output value. + */ + @Generated + public String getOutput() { + return this.output; + } + + /** + * Set the output property: The output from the tool to be submitted. + * + * @param output the output value to set. + * @return the ToolOutput object itself. + */ + @Generated + public ToolOutput setOutput(String output) { + this.output = output; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("tool_call_id", this.toolCallId); + jsonWriter.writeStringField("output", this.output); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ToolOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ToolOutput if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the ToolOutput. + */ + @Generated + public static ToolOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ToolOutput deserializedToolOutput = new ToolOutput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("tool_call_id".equals(fieldName)) { + deserializedToolOutput.toolCallId = reader.getString(); + } else if ("output".equals(fieldName)) { + deserializedToolOutput.output = reader.getString(); + } else { + reader.skipChildren(); + } + } + return deserializedToolOutput; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolResources.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolResources.java new file mode 100644 index 000000000000..9a299e22d1d9 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolResources.java @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A set of resources that are used by the agent's tools. The resources are specific to the type of + * tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` + * tool requires a list of vector store IDs. + */ +@Fluent +public final class ToolResources implements JsonSerializable { + + /* + * Resources to be used by the `code_interpreter` tool consisting of file IDs. + */ + @Generated + private CodeInterpreterToolResource codeInterpreter; + + /* + * Resources to be used by the `file_search` tool consisting of vector store IDs. + */ + @Generated + private FileSearchToolResource fileSearch; + + /* + * Resources to be used by the `azure_ai_search` tool consisting of index IDs and names. + */ + @Generated + private AzureAISearchResource azureAISearch; + + /** + * Creates an instance of ToolResources class. + */ + @Generated + public ToolResources() { + } + + /** + * Get the codeInterpreter property: Resources to be used by the `code_interpreter` tool consisting of file IDs. + * + * @return the codeInterpreter value. + */ + @Generated + public CodeInterpreterToolResource getCodeInterpreter() { + return this.codeInterpreter; + } + + /** + * Set the codeInterpreter property: Resources to be used by the `code_interpreter` tool consisting of file IDs. + * + * @param codeInterpreter the codeInterpreter value to set. + * @return the ToolResources object itself. + */ + @Generated + public ToolResources setCodeInterpreter(CodeInterpreterToolResource codeInterpreter) { + this.codeInterpreter = codeInterpreter; + return this; + } + + /** + * Get the fileSearch property: Resources to be used by the `file_search` tool consisting of vector store IDs. + * + * @return the fileSearch value. + */ + @Generated + public FileSearchToolResource getFileSearch() { + return this.fileSearch; + } + + /** + * Set the fileSearch property: Resources to be used by the `file_search` tool consisting of vector store IDs. + * + * @param fileSearch the fileSearch value to set. + * @return the ToolResources object itself. + */ + @Generated + public ToolResources setFileSearch(FileSearchToolResource fileSearch) { + this.fileSearch = fileSearch; + return this; + } + + /** + * Get the azureAISearch property: Resources to be used by the `azure_ai_search` tool consisting of index IDs and + * names. + * + * @return the azureAISearch value. + */ + @Generated + public AzureAISearchResource getAzureAISearch() { + return this.azureAISearch; + } + + /** + * Set the azureAISearch property: Resources to be used by the `azure_ai_search` tool consisting of index IDs and + * names. + * + * @param azureAISearch the azureAISearch value to set. + * @return the ToolResources object itself. + */ + @Generated + public ToolResources setAzureAISearch(AzureAISearchResource azureAISearch) { + this.azureAISearch = azureAISearch; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("code_interpreter", this.codeInterpreter); + jsonWriter.writeJsonField("file_search", this.fileSearch); + jsonWriter.writeJsonField("azure_ai_search", this.azureAISearch); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ToolResources from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ToolResources if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ToolResources. + */ + @Generated + public static ToolResources fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ToolResources deserializedToolResources = new ToolResources(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("code_interpreter".equals(fieldName)) { + deserializedToolResources.codeInterpreter = CodeInterpreterToolResource.fromJson(reader); + } else if ("file_search".equals(fieldName)) { + deserializedToolResources.fileSearch = FileSearchToolResource.fromJson(reader); + } else if ("azure_ai_search".equals(fieldName)) { + deserializedToolResources.azureAISearch = AzureAISearchResource.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedToolResources; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/TruncationObject.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/TruncationObject.java new file mode 100644 index 000000000000..f6f4a435c55f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/TruncationObject.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Controls for how a thread will be truncated prior to the run. Use this to control the initial + * context window of the run. + */ +@Fluent +public final class TruncationObject implements JsonSerializable { + + /* + * The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will + * be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the + * middle of the thread + * will be dropped to fit the context length of the model, `max_prompt_tokens`. + */ + @Generated + private final TruncationStrategy type; + + /* + * The number of most recent messages from the thread when constructing the context for the run. + */ + @Generated + private Integer lastMessages; + + /** + * Creates an instance of TruncationObject class. + * + * @param type the type value to set. + */ + @Generated + public TruncationObject(TruncationStrategy type) { + this.type = type; + } + + /** + * Get the type property: The truncation strategy to use for the thread. The default is `auto`. If set to + * `last_messages`, the thread will + * be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the + * middle of the thread + * will be dropped to fit the context length of the model, `max_prompt_tokens`. + * + * @return the type value. + */ + @Generated + public TruncationStrategy getType() { + return this.type; + } + + /** + * Get the lastMessages property: The number of most recent messages from the thread when constructing the context + * for the run. + * + * @return the lastMessages value. + */ + @Generated + public Integer getLastMessages() { + return this.lastMessages; + } + + /** + * Set the lastMessages property: The number of most recent messages from the thread when constructing the context + * for the run. + * + * @param lastMessages the lastMessages value to set. + * @return the TruncationObject object itself. + */ + @Generated + public TruncationObject setLastMessages(Integer lastMessages) { + this.lastMessages = lastMessages; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeNumberField("last_messages", this.lastMessages); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TruncationObject from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TruncationObject if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TruncationObject. + */ + @Generated + public static TruncationObject fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TruncationStrategy type = null; + Integer lastMessages = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + type = TruncationStrategy.fromString(reader.getString()); + } else if ("last_messages".equals(fieldName)) { + lastMessages = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + TruncationObject deserializedTruncationObject = new TruncationObject(type); + deserializedTruncationObject.lastMessages = lastMessages; + return deserializedTruncationObject; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/TruncationStrategy.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/TruncationStrategy.java new file mode 100644 index 000000000000..4ed65b37eb7d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/TruncationStrategy.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Possible truncation strategies for the thread. + */ +public final class TruncationStrategy extends ExpandableStringEnum { + + /** + * Default value. Messages in the middle of the thread will be dropped to fit the context length of the model. + */ + @Generated + public static final TruncationStrategy AUTO = fromString("auto"); + + /** + * The thread will truncate to the `lastMessages` count of recent messages. + */ + @Generated + public static final TruncationStrategy LAST_MESSAGES = fromString("last_messages"); + + /** + * Creates a new instance of TruncationStrategy value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public TruncationStrategy() { + } + + /** + * Creates or finds a TruncationStrategy from its string representation. + * + * @param name a name to look for. + * @return the corresponding TruncationStrategy. + */ + @Generated + public static TruncationStrategy fromString(String name) { + return fromString(name, TruncationStrategy.class); + } + + /** + * Gets known TruncationStrategy values. + * + * @return known TruncationStrategy values. + */ + @Generated + public static Collection values() { + return values(TruncationStrategy.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateAgentOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateAgentOptions.java new file mode 100644 index 000000000000..7b7e5ed66cb7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateAgentOptions.java @@ -0,0 +1,355 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; +import java.util.List; +import java.util.Map; + +/** + * Options for updateAgent API. + */ +@Fluent +public final class UpdateAgentOptions { + + /* + * The ID of the agent to modify. + */ + @Generated + private final String assistantId; + + /* + * The ID of the model to use. + */ + @Generated + private String model; + + /* + * The modified name for the agent to use. + */ + @Generated + private String name; + + /* + * The modified description for the agent to use. + */ + @Generated + private String description; + + /* + * The modified system instructions for the new agent to use. + */ + @Generated + private String instructions; + + /* + * The modified collection of tools to enable for the agent. + */ + @Generated + private List tools; + + /* + * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For + * example, + * the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector + * store IDs. + */ + @Generated + private ToolResources toolResources; + + /* + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + */ + @Generated + private Double temperature; + + /* + * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of + * the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + */ + @Generated + private Double topP; + + /* + * The response format of the tool calls used by this agent. + */ + @Generated + private BinaryData responseFormat; + + /* + * 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. + */ + @Generated + private Map metadata; + + /** + * Creates an instance of UpdateAgentOptions class. + * + * @param assistantId the assistantId value to set. + */ + @Generated + public UpdateAgentOptions(String assistantId) { + this.assistantId = assistantId; + } + + /** + * Get the assistantId property: The ID of the agent to modify. + * + * @return the assistantId value. + */ + @Generated + public String getAssistantId() { + return this.assistantId; + } + + /** + * Get the model property: The ID of the model to use. + * + * @return the model value. + */ + @Generated + public String getModel() { + return this.model; + } + + /** + * Set the model property: The ID of the model to use. + * + * @param model the model value to set. + * @return the UpdateAgentOptions object itself. + */ + @Generated + public UpdateAgentOptions setModel(String model) { + this.model = model; + return this; + } + + /** + * Get the name property: The modified name for the agent to use. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The modified name for the agent to use. + * + * @param name the name value to set. + * @return the UpdateAgentOptions object itself. + */ + @Generated + public UpdateAgentOptions setName(String name) { + this.name = name; + return this; + } + + /** + * Get the description property: The modified description for the agent to use. + * + * @return the description value. + */ + @Generated + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The modified description for the agent to use. + * + * @param description the description value to set. + * @return the UpdateAgentOptions object itself. + */ + @Generated + public UpdateAgentOptions setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the instructions property: The modified system instructions for the new agent to use. + * + * @return the instructions value. + */ + @Generated + public String getInstructions() { + return this.instructions; + } + + /** + * Set the instructions property: The modified system instructions for the new agent to use. + * + * @param instructions the instructions value to set. + * @return the UpdateAgentOptions object itself. + */ + @Generated + public UpdateAgentOptions setInstructions(String instructions) { + this.instructions = instructions; + return this; + } + + /** + * Get the tools property: The modified collection of tools to enable for the agent. + * + * @return the tools value. + */ + @Generated + public List getTools() { + return this.tools; + } + + /** + * Set the tools property: The modified collection of tools to enable for the agent. + * + * @param tools the tools value to set. + * @return the UpdateAgentOptions object itself. + */ + @Generated + public UpdateAgentOptions setTools(List tools) { + this.tools = tools; + return this; + } + + /** + * Get the toolResources property: A set of resources that are used by the agent's tools. The resources are specific + * to the type of tool. For example, + * the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector + * store IDs. + * + * @return the toolResources value. + */ + @Generated + public ToolResources getToolResources() { + return this.toolResources; + } + + /** + * Set the toolResources property: A set of resources that are used by the agent's tools. The resources are specific + * to the type of tool. For example, + * the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector + * store IDs. + * + * @param toolResources the toolResources value to set. + * @return the UpdateAgentOptions object itself. + */ + @Generated + public UpdateAgentOptions setToolResources(ToolResources toolResources) { + this.toolResources = toolResources; + return this; + } + + /** + * Get the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + * + * @return the temperature value. + */ + @Generated + public Double getTemperature() { + return this.temperature; + } + + /** + * Set the temperature property: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make + * the output more random, + * while lower values like 0.2 will make it more focused and deterministic. + * + * @param temperature the temperature value to set. + * @return the UpdateAgentOptions object itself. + */ + @Generated + public UpdateAgentOptions setTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + /** + * Get the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @return the topP value. + */ + @Generated + public Double getTopP() { + return this.topP; + } + + /** + * Set the topP property: An alternative to sampling with temperature, called nucleus sampling, where the model + * considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @param topP the topP value to set. + * @return the UpdateAgentOptions object itself. + */ + @Generated + public UpdateAgentOptions setTopP(Double topP) { + this.topP = topP; + return this; + } + + /** + * Get the responseFormat property: The response format of the tool calls used by this agent. + * + * @return the responseFormat value. + */ + @Generated + public BinaryData getResponseFormat() { + return this.responseFormat; + } + + /** + * Set the responseFormat property: The response format of the tool calls used by this agent. + * + * @param responseFormat the responseFormat value to set. + * @return the UpdateAgentOptions object itself. + */ + @Generated + public UpdateAgentOptions setResponseFormat(BinaryData responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * Set the metadata property: 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. + * + * @param metadata the metadata value to set. + * @return the UpdateAgentOptions object itself. + */ + @Generated + public UpdateAgentOptions setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateCodeInterpreterToolResourceOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateCodeInterpreterToolResourceOptions.java new file mode 100644 index 000000000000..120a1cac97eb --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateCodeInterpreterToolResourceOptions.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Request object to update `code_interpreted` tool resources. + */ +@Fluent +public final class UpdateCodeInterpreterToolResourceOptions + implements JsonSerializable { + + /* + * A list of file IDs to override the current list of the agent. + */ + @Generated + private List fileIds; + + /** + * Creates an instance of UpdateCodeInterpreterToolResourceOptions class. + */ + @Generated + public UpdateCodeInterpreterToolResourceOptions() { + } + + /** + * Get the fileIds property: A list of file IDs to override the current list of the agent. + * + * @return the fileIds value. + */ + @Generated + public List getFileIds() { + return this.fileIds; + } + + /** + * Set the fileIds property: A list of file IDs to override the current list of the agent. + * + * @param fileIds the fileIds value to set. + * @return the UpdateCodeInterpreterToolResourceOptions object itself. + */ + @Generated + public UpdateCodeInterpreterToolResourceOptions setFileIds(List fileIds) { + this.fileIds = fileIds; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("file_ids", this.fileIds, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UpdateCodeInterpreterToolResourceOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UpdateCodeInterpreterToolResourceOptions if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the UpdateCodeInterpreterToolResourceOptions. + */ + @Generated + public static UpdateCodeInterpreterToolResourceOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UpdateCodeInterpreterToolResourceOptions deserializedUpdateCodeInterpreterToolResourceOptions + = new UpdateCodeInterpreterToolResourceOptions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("file_ids".equals(fieldName)) { + List fileIds = reader.readArray(reader1 -> reader1.getString()); + deserializedUpdateCodeInterpreterToolResourceOptions.fileIds = fileIds; + } else { + reader.skipChildren(); + } + } + return deserializedUpdateCodeInterpreterToolResourceOptions; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateFileSearchToolResourceOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateFileSearchToolResourceOptions.java new file mode 100644 index 000000000000..85854490119c --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateFileSearchToolResourceOptions.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Request object to update `file_search` tool resources. + */ +@Fluent +public final class UpdateFileSearchToolResourceOptions + implements JsonSerializable { + + /* + * A list of vector store IDs to override the current list of the agent. + */ + @Generated + private List vectorStoreIds; + + /** + * Creates an instance of UpdateFileSearchToolResourceOptions class. + */ + @Generated + public UpdateFileSearchToolResourceOptions() { + } + + /** + * Get the vectorStoreIds property: A list of vector store IDs to override the current list of the agent. + * + * @return the vectorStoreIds value. + */ + @Generated + public List getVectorStoreIds() { + return this.vectorStoreIds; + } + + /** + * Set the vectorStoreIds property: A list of vector store IDs to override the current list of the agent. + * + * @param vectorStoreIds the vectorStoreIds value to set. + * @return the UpdateFileSearchToolResourceOptions object itself. + */ + @Generated + public UpdateFileSearchToolResourceOptions setVectorStoreIds(List vectorStoreIds) { + this.vectorStoreIds = vectorStoreIds; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("vector_store_ids", this.vectorStoreIds, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UpdateFileSearchToolResourceOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UpdateFileSearchToolResourceOptions if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the UpdateFileSearchToolResourceOptions. + */ + @Generated + public static UpdateFileSearchToolResourceOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UpdateFileSearchToolResourceOptions deserializedUpdateFileSearchToolResourceOptions + = new UpdateFileSearchToolResourceOptions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("vector_store_ids".equals(fieldName)) { + List vectorStoreIds = reader.readArray(reader1 -> reader1.getString()); + deserializedUpdateFileSearchToolResourceOptions.vectorStoreIds = vectorStoreIds; + } else { + reader.skipChildren(); + } + } + return deserializedUpdateFileSearchToolResourceOptions; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateToolResourcesOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateToolResourcesOptions.java new file mode 100644 index 000000000000..001b96ad6c37 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/UpdateToolResourcesOptions.java @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Request object. A set of resources that are used by the agent's tools. The resources are specific to the type of + * tool. + * For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of + * vector store IDs. + */ +@Fluent +public final class UpdateToolResourcesOptions implements JsonSerializable { + + /* + * Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + * associated with the tool. + */ + @Generated + private UpdateCodeInterpreterToolResourceOptions codeInterpreter; + + /* + * Overrides the vector store attached to this agent. There can be a maximum of 1 vector store attached to the + * agent. + */ + @Generated + private UpdateFileSearchToolResourceOptions fileSearch; + + /* + * Overrides the resources to be used by the `azure_ai_search` tool consisting of index IDs and names. + */ + @Generated + private AzureAISearchResource azureAISearch; + + /** + * Creates an instance of UpdateToolResourcesOptions class. + */ + @Generated + public UpdateToolResourcesOptions() { + } + + /** + * Get the codeInterpreter property: Overrides the list of file IDs made available to the `code_interpreter` tool. + * There can be a maximum of 20 files + * associated with the tool. + * + * @return the codeInterpreter value. + */ + @Generated + public UpdateCodeInterpreterToolResourceOptions getCodeInterpreter() { + return this.codeInterpreter; + } + + /** + * Set the codeInterpreter property: Overrides the list of file IDs made available to the `code_interpreter` tool. + * There can be a maximum of 20 files + * associated with the tool. + * + * @param codeInterpreter the codeInterpreter value to set. + * @return the UpdateToolResourcesOptions object itself. + */ + @Generated + public UpdateToolResourcesOptions setCodeInterpreter(UpdateCodeInterpreterToolResourceOptions codeInterpreter) { + this.codeInterpreter = codeInterpreter; + return this; + } + + /** + * Get the fileSearch property: Overrides the vector store attached to this agent. There can be a maximum of 1 + * vector store attached to the agent. + * + * @return the fileSearch value. + */ + @Generated + public UpdateFileSearchToolResourceOptions getFileSearch() { + return this.fileSearch; + } + + /** + * Set the fileSearch property: Overrides the vector store attached to this agent. There can be a maximum of 1 + * vector store attached to the agent. + * + * @param fileSearch the fileSearch value to set. + * @return the UpdateToolResourcesOptions object itself. + */ + @Generated + public UpdateToolResourcesOptions setFileSearch(UpdateFileSearchToolResourceOptions fileSearch) { + this.fileSearch = fileSearch; + return this; + } + + /** + * Get the azureAISearch property: Overrides the resources to be used by the `azure_ai_search` tool consisting of + * index IDs and names. + * + * @return the azureAISearch value. + */ + @Generated + public AzureAISearchResource getAzureAISearch() { + return this.azureAISearch; + } + + /** + * Set the azureAISearch property: Overrides the resources to be used by the `azure_ai_search` tool consisting of + * index IDs and names. + * + * @param azureAISearch the azureAISearch value to set. + * @return the UpdateToolResourcesOptions object itself. + */ + @Generated + public UpdateToolResourcesOptions setAzureAISearch(AzureAISearchResource azureAISearch) { + this.azureAISearch = azureAISearch; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("code_interpreter", this.codeInterpreter); + jsonWriter.writeJsonField("file_search", this.fileSearch); + jsonWriter.writeJsonField("azure_ai_search", this.azureAISearch); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UpdateToolResourcesOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UpdateToolResourcesOptions if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the UpdateToolResourcesOptions. + */ + @Generated + public static UpdateToolResourcesOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UpdateToolResourcesOptions deserializedUpdateToolResourcesOptions = new UpdateToolResourcesOptions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("code_interpreter".equals(fieldName)) { + deserializedUpdateToolResourcesOptions.codeInterpreter + = UpdateCodeInterpreterToolResourceOptions.fromJson(reader); + } else if ("file_search".equals(fieldName)) { + deserializedUpdateToolResourcesOptions.fileSearch + = UpdateFileSearchToolResourceOptions.fromJson(reader); + } else if ("azure_ai_search".equals(fieldName)) { + deserializedUpdateToolResourcesOptions.azureAISearch = AzureAISearchResource.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return deserializedUpdateToolResourcesOptions; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStore.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStore.java new file mode 100644 index 000000000000..b57ecb689d82 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStore.java @@ -0,0 +1,327 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.Map; + +/** + * A vector store is a collection of processed files can be used by the `file_search` tool. + */ +@Immutable +public final class VectorStore implements JsonSerializable { + + /* + * The identifier, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The object type, which is always `vector_store` + */ + @Generated + private final String object = "vector_store"; + + /* + * The Unix timestamp (in seconds) for when the vector store was created. + */ + @Generated + private final long createdAt; + + /* + * The name of the vector store. + */ + @Generated + private final String name; + + /* + * The total number of bytes used by the files in the vector store. + */ + @Generated + private final int usageBytes; + + /* + * Files count grouped by status processed or being processed by this vector store. + */ + @Generated + private final VectorStoreFileCount fileCounts; + + /* + * The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of + * `completed` indicates that the vector store is ready for use. + */ + @Generated + private final VectorStoreStatus status; + + /* + * Details on when this vector store expires + */ + @Generated + private VectorStoreExpirationPolicy expiresAfter; + + /* + * The Unix timestamp (in seconds) for when the vector store will expire. + */ + @Generated + private Long expiresAt; + + /* + * The Unix timestamp (in seconds) for when the vector store was last active. + */ + @Generated + private final Long lastActiveAt; + + /* + * 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. + */ + @Generated + private final Map metadata; + + /** + * Creates an instance of VectorStore class. + * + * @param id the id value to set. + * @param createdAt the createdAt value to set. + * @param name the name value to set. + * @param usageBytes the usageBytes value to set. + * @param fileCounts the fileCounts value to set. + * @param status the status value to set. + * @param lastActiveAt the lastActiveAt value to set. + * @param metadata the metadata value to set. + */ + @Generated + private VectorStore(String id, OffsetDateTime createdAt, String name, int usageBytes, + VectorStoreFileCount fileCounts, VectorStoreStatus status, OffsetDateTime lastActiveAt, + Map metadata) { + this.id = id; + if (createdAt == null) { + this.createdAt = 0L; + } else { + this.createdAt = createdAt.toEpochSecond(); + } + this.name = name; + this.usageBytes = usageBytes; + this.fileCounts = fileCounts; + this.status = status; + if (lastActiveAt == null) { + this.lastActiveAt = null; + } else { + this.lastActiveAt = lastActiveAt.toEpochSecond(); + } + this.metadata = metadata; + } + + /** + * Get the id property: The identifier, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the object property: The object type, which is always `vector_store`. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the createdAt property: The Unix timestamp (in seconds) for when the vector store was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC); + } + + /** + * Get the name property: The name of the vector store. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the usageBytes property: The total number of bytes used by the files in the vector store. + * + * @return the usageBytes value. + */ + @Generated + public int getUsageBytes() { + return this.usageBytes; + } + + /** + * Get the fileCounts property: Files count grouped by status processed or being processed by this vector store. + * + * @return the fileCounts value. + */ + @Generated + public VectorStoreFileCount getFileCounts() { + return this.fileCounts; + } + + /** + * Get the status property: The status of the vector store, which can be either `expired`, `in_progress`, or + * `completed`. A status of `completed` indicates that the vector store is ready for use. + * + * @return the status value. + */ + @Generated + public VectorStoreStatus getStatus() { + return this.status; + } + + /** + * Get the expiresAfter property: Details on when this vector store expires. + * + * @return the expiresAfter value. + */ + @Generated + public VectorStoreExpirationPolicy getExpiresAfter() { + return this.expiresAfter; + } + + /** + * Get the expiresAt property: The Unix timestamp (in seconds) for when the vector store will expire. + * + * @return the expiresAt value. + */ + @Generated + public OffsetDateTime getExpiresAt() { + if (this.expiresAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.expiresAt), ZoneOffset.UTC); + } + + /** + * Get the lastActiveAt property: The Unix timestamp (in seconds) for when the vector store was last active. + * + * @return the lastActiveAt value. + */ + @Generated + public OffsetDateTime getLastActiveAt() { + if (this.lastActiveAt == null) { + return null; + } + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.lastActiveAt), ZoneOffset.UTC); + } + + /** + * Get the metadata property: 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. + * + * @return the metadata value. + */ + @Generated + public Map getMetadata() { + return this.metadata; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeLongField("created_at", this.createdAt); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeIntField("usage_bytes", this.usageBytes); + jsonWriter.writeJsonField("file_counts", this.fileCounts); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeNumberField("last_active_at", this.lastActiveAt); + jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("expires_after", this.expiresAfter); + jsonWriter.writeNumberField("expires_at", this.expiresAt); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStore from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStore if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStore. + */ + @Generated + public static VectorStore fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OffsetDateTime createdAt = null; + String name = null; + int usageBytes = 0; + VectorStoreFileCount fileCounts = null; + VectorStoreStatus status = null; + OffsetDateTime lastActiveAt = null; + Map metadata = null; + VectorStoreExpirationPolicy expiresAfter = null; + Long expiresAt = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("created_at".equals(fieldName)) { + createdAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader.getLong()), ZoneOffset.UTC); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("usage_bytes".equals(fieldName)) { + usageBytes = reader.getInt(); + } else if ("file_counts".equals(fieldName)) { + fileCounts = VectorStoreFileCount.fromJson(reader); + } else if ("status".equals(fieldName)) { + status = VectorStoreStatus.fromString(reader.getString()); + } else if ("last_active_at".equals(fieldName)) { + Long lastActiveAtHolder = reader.getNullable(JsonReader::getLong); + if (lastActiveAtHolder != null) { + lastActiveAt + = OffsetDateTime.ofInstant(Instant.ofEpochSecond(lastActiveAtHolder), ZoneOffset.UTC); + } + } else if ("metadata".equals(fieldName)) { + metadata = reader.readMap(reader1 -> reader1.getString()); + } else if ("expires_after".equals(fieldName)) { + expiresAfter = VectorStoreExpirationPolicy.fromJson(reader); + } else if ("expires_at".equals(fieldName)) { + expiresAt = reader.getNullable(JsonReader::getLong); + } else { + reader.skipChildren(); + } + } + VectorStore deserializedVectorStore + = new VectorStore(id, createdAt, name, usageBytes, fileCounts, status, lastActiveAt, metadata); + deserializedVectorStore.expiresAfter = expiresAfter; + deserializedVectorStore.expiresAt = expiresAt; + return deserializedVectorStore; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreAutoChunkingStrategyRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreAutoChunkingStrategyRequest.java new file mode 100644 index 000000000000..d8be6fbecd2c --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreAutoChunkingStrategyRequest.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The default strategy. This strategy currently uses a max_chunk_size_tokens of 800 and chunk_overlap_tokens of 400. + */ +@Immutable +public final class VectorStoreAutoChunkingStrategyRequest extends VectorStoreChunkingStrategyRequest { + + /* + * The object type. + */ + @Generated + private VectorStoreChunkingStrategyRequestType type = VectorStoreChunkingStrategyRequestType.AUTO; + + /** + * Creates an instance of VectorStoreAutoChunkingStrategyRequest class. + */ + @Generated + public VectorStoreAutoChunkingStrategyRequest() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public VectorStoreChunkingStrategyRequestType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreAutoChunkingStrategyRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreAutoChunkingStrategyRequest if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the VectorStoreAutoChunkingStrategyRequest. + */ + @Generated + public static VectorStoreAutoChunkingStrategyRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VectorStoreAutoChunkingStrategyRequest deserializedVectorStoreAutoChunkingStrategyRequest + = new VectorStoreAutoChunkingStrategyRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedVectorStoreAutoChunkingStrategyRequest.type + = VectorStoreChunkingStrategyRequestType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedVectorStoreAutoChunkingStrategyRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreAutoChunkingStrategyResponse.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreAutoChunkingStrategyResponse.java new file mode 100644 index 000000000000..84c246f269c5 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreAutoChunkingStrategyResponse.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the + * chunking_strategy concept was introduced in the API. + */ +@Immutable +public final class VectorStoreAutoChunkingStrategyResponse extends VectorStoreChunkingStrategyResponse { + + /* + * The object type. + */ + @Generated + private VectorStoreChunkingStrategyResponseType type = VectorStoreChunkingStrategyResponseType.OTHER; + + /** + * Creates an instance of VectorStoreAutoChunkingStrategyResponse class. + */ + @Generated + private VectorStoreAutoChunkingStrategyResponse() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public VectorStoreChunkingStrategyResponseType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreAutoChunkingStrategyResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreAutoChunkingStrategyResponse if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the VectorStoreAutoChunkingStrategyResponse. + */ + @Generated + public static VectorStoreAutoChunkingStrategyResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VectorStoreAutoChunkingStrategyResponse deserializedVectorStoreAutoChunkingStrategyResponse + = new VectorStoreAutoChunkingStrategyResponse(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedVectorStoreAutoChunkingStrategyResponse.type + = VectorStoreChunkingStrategyResponseType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedVectorStoreAutoChunkingStrategyResponse; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyRequest.java new file mode 100644 index 000000000000..6df2316e5c12 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyRequest.java @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An abstract representation of a vector store chunking strategy configuration. + */ +@Immutable +public class VectorStoreChunkingStrategyRequest implements JsonSerializable { + + /* + * The object type. + */ + @Generated + private VectorStoreChunkingStrategyRequestType type + = VectorStoreChunkingStrategyRequestType.fromString("VectorStoreChunkingStrategyRequest"); + + /** + * Creates an instance of VectorStoreChunkingStrategyRequest class. + */ + @Generated + public VectorStoreChunkingStrategyRequest() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + public VectorStoreChunkingStrategyRequestType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreChunkingStrategyRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreChunkingStrategyRequest if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the VectorStoreChunkingStrategyRequest. + */ + @Generated + public static VectorStoreChunkingStrategyRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("auto".equals(discriminatorValue)) { + return VectorStoreAutoChunkingStrategyRequest.fromJson(readerToUse.reset()); + } else if ("static".equals(discriminatorValue)) { + return VectorStoreStaticChunkingStrategyRequest.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static VectorStoreChunkingStrategyRequest fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VectorStoreChunkingStrategyRequest deserializedVectorStoreChunkingStrategyRequest + = new VectorStoreChunkingStrategyRequest(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedVectorStoreChunkingStrategyRequest.type + = VectorStoreChunkingStrategyRequestType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedVectorStoreChunkingStrategyRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyRequestType.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyRequestType.java new file mode 100644 index 000000000000..ffd496276b65 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyRequestType.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of chunking strategy. + */ +public final class VectorStoreChunkingStrategyRequestType + extends ExpandableStringEnum { + + /** + * Static value auto for VectorStoreChunkingStrategyRequestType. + */ + @Generated + public static final VectorStoreChunkingStrategyRequestType AUTO = fromString("auto"); + + /** + * Static value static for VectorStoreChunkingStrategyRequestType. + */ + @Generated + public static final VectorStoreChunkingStrategyRequestType STATIC = fromString("static"); + + /** + * Creates a new instance of VectorStoreChunkingStrategyRequestType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public VectorStoreChunkingStrategyRequestType() { + } + + /** + * Creates or finds a VectorStoreChunkingStrategyRequestType from its string representation. + * + * @param name a name to look for. + * @return the corresponding VectorStoreChunkingStrategyRequestType. + */ + @Generated + public static VectorStoreChunkingStrategyRequestType fromString(String name) { + return fromString(name, VectorStoreChunkingStrategyRequestType.class); + } + + /** + * Gets known VectorStoreChunkingStrategyRequestType values. + * + * @return known VectorStoreChunkingStrategyRequestType values. + */ + @Generated + public static Collection values() { + return values(VectorStoreChunkingStrategyRequestType.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyResponse.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyResponse.java new file mode 100644 index 000000000000..1a8974d07ba6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyResponse.java @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An abstract representation of a vector store chunking strategy configuration. + */ +@Immutable +public class VectorStoreChunkingStrategyResponse implements JsonSerializable { + + /* + * The object type. + */ + @Generated + private VectorStoreChunkingStrategyResponseType type + = VectorStoreChunkingStrategyResponseType.fromString("VectorStoreChunkingStrategyResponse"); + + /** + * Creates an instance of VectorStoreChunkingStrategyResponse class. + */ + @Generated + protected VectorStoreChunkingStrategyResponse() { + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + public VectorStoreChunkingStrategyResponseType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreChunkingStrategyResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreChunkingStrategyResponse if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the VectorStoreChunkingStrategyResponse. + */ + @Generated + public static VectorStoreChunkingStrategyResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + // Prepare for reading + readerToUse.nextToken(); + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("other".equals(discriminatorValue)) { + return VectorStoreAutoChunkingStrategyResponse.fromJson(readerToUse.reset()); + } else if ("static".equals(discriminatorValue)) { + return VectorStoreStaticChunkingStrategyResponse.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static VectorStoreChunkingStrategyResponse fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VectorStoreChunkingStrategyResponse deserializedVectorStoreChunkingStrategyResponse + = new VectorStoreChunkingStrategyResponse(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("type".equals(fieldName)) { + deserializedVectorStoreChunkingStrategyResponse.type + = VectorStoreChunkingStrategyResponseType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return deserializedVectorStoreChunkingStrategyResponse; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyResponseType.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyResponseType.java new file mode 100644 index 000000000000..f7a4f5f322c8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreChunkingStrategyResponseType.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of chunking strategy. + */ +public final class VectorStoreChunkingStrategyResponseType + extends ExpandableStringEnum { + + /** + * Static value other for VectorStoreChunkingStrategyResponseType. + */ + @Generated + public static final VectorStoreChunkingStrategyResponseType OTHER = fromString("other"); + + /** + * Static value static for VectorStoreChunkingStrategyResponseType. + */ + @Generated + public static final VectorStoreChunkingStrategyResponseType STATIC = fromString("static"); + + /** + * Creates a new instance of VectorStoreChunkingStrategyResponseType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public VectorStoreChunkingStrategyResponseType() { + } + + /** + * Creates or finds a VectorStoreChunkingStrategyResponseType from its string representation. + * + * @param name a name to look for. + * @return the corresponding VectorStoreChunkingStrategyResponseType. + */ + @Generated + public static VectorStoreChunkingStrategyResponseType fromString(String name) { + return fromString(name, VectorStoreChunkingStrategyResponseType.class); + } + + /** + * Gets known VectorStoreChunkingStrategyResponseType values. + * + * @return known VectorStoreChunkingStrategyResponseType values. + */ + @Generated + public static Collection values() { + return values(VectorStoreChunkingStrategyResponseType.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreConfiguration.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreConfiguration.java new file mode 100644 index 000000000000..75043ece4569 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreConfiguration.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Vector storage configuration is the list of data sources, used when multiple + * files can be used for the enterprise file search. + */ +@Immutable +public final class VectorStoreConfiguration implements JsonSerializable { + + /* + * Data sources + */ + @Generated + private final List dataSources; + + /** + * Creates an instance of VectorStoreConfiguration class. + * + * @param dataSources the dataSources value to set. + */ + @Generated + public VectorStoreConfiguration(List dataSources) { + this.dataSources = dataSources; + } + + /** + * Get the dataSources property: Data sources. + * + * @return the dataSources value. + */ + @Generated + public List getDataSources() { + return this.dataSources; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("data_sources", this.dataSources, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreConfiguration from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreConfiguration if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreConfiguration. + */ + @Generated + public static VectorStoreConfiguration fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List dataSources = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("data_sources".equals(fieldName)) { + dataSources = reader.readArray(reader1 -> VectorStoreDataSource.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new VectorStoreConfiguration(dataSources); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreConfigurations.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreConfigurations.java new file mode 100644 index 000000000000..947033ebbf20 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreConfigurations.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The structure, containing the list of vector storage configurations i.e. the list of azure asset IDs. + */ +@Immutable +public final class VectorStoreConfigurations implements JsonSerializable { + + /* + * Name + */ + @Generated + private final String storeName; + + /* + * Configurations + */ + @Generated + private final VectorStoreConfiguration storeConfiguration; + + /** + * Creates an instance of VectorStoreConfigurations class. + * + * @param storeName the storeName value to set. + * @param storeConfiguration the storeConfiguration value to set. + */ + @Generated + public VectorStoreConfigurations(String storeName, VectorStoreConfiguration storeConfiguration) { + this.storeName = storeName; + this.storeConfiguration = storeConfiguration; + } + + /** + * Get the storeName property: Name. + * + * @return the storeName value. + */ + @Generated + public String getStoreName() { + return this.storeName; + } + + /** + * Get the storeConfiguration property: Configurations. + * + * @return the storeConfiguration value. + */ + @Generated + public VectorStoreConfiguration getStoreConfiguration() { + return this.storeConfiguration; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.storeName); + jsonWriter.writeJsonField("configuration", this.storeConfiguration); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreConfigurations from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreConfigurations if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreConfigurations. + */ + @Generated + public static VectorStoreConfigurations fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String storeName = null; + VectorStoreConfiguration storeConfiguration = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("name".equals(fieldName)) { + storeName = reader.getString(); + } else if ("configuration".equals(fieldName)) { + storeConfiguration = VectorStoreConfiguration.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new VectorStoreConfigurations(storeName, storeConfiguration); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDataSource.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDataSource.java new file mode 100644 index 000000000000..bd0e6cc731f5 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDataSource.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The structure, containing Azure asset URI path and the asset type of the file used as a data source + * for the enterprise file search. + */ +@Immutable +public final class VectorStoreDataSource implements JsonSerializable { + + /* + * Asset URI. + */ + @Generated + private final String assetIdentifier; + + /* + * The asset type + */ + @Generated + private final VectorStoreDataSourceAssetType assetType; + + /** + * Creates an instance of VectorStoreDataSource class. + * + * @param assetIdentifier the assetIdentifier value to set. + * @param assetType the assetType value to set. + */ + @Generated + public VectorStoreDataSource(String assetIdentifier, VectorStoreDataSourceAssetType assetType) { + this.assetIdentifier = assetIdentifier; + this.assetType = assetType; + } + + /** + * Get the assetIdentifier property: Asset URI. + * + * @return the assetIdentifier value. + */ + @Generated + public String getAssetIdentifier() { + return this.assetIdentifier; + } + + /** + * Get the assetType property: The asset type. + * + * @return the assetType value. + */ + @Generated + public VectorStoreDataSourceAssetType getAssetType() { + return this.assetType; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("uri", this.assetIdentifier); + jsonWriter.writeStringField("type", this.assetType == null ? null : this.assetType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreDataSource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreDataSource if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreDataSource. + */ + @Generated + public static VectorStoreDataSource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String assetIdentifier = null; + VectorStoreDataSourceAssetType assetType = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("uri".equals(fieldName)) { + assetIdentifier = reader.getString(); + } else if ("type".equals(fieldName)) { + assetType = VectorStoreDataSourceAssetType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new VectorStoreDataSource(assetIdentifier, assetType); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDataSourceAssetType.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDataSourceAssetType.java new file mode 100644 index 000000000000..f2e4d757d5ae --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDataSourceAssetType.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of vector storage asset. Asset type may be a uri_asset, in this case it should contain asset URI ID, + * in the case of id_asset it should contain the data ID. + */ +public final class VectorStoreDataSourceAssetType extends ExpandableStringEnum { + + /** + * Azure URI. + */ + @Generated + public static final VectorStoreDataSourceAssetType URI_ASSET = fromString("uri_asset"); + + /** + * The data ID. + */ + @Generated + public static final VectorStoreDataSourceAssetType ID_ASSET = fromString("id_asset"); + + /** + * Creates a new instance of VectorStoreDataSourceAssetType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public VectorStoreDataSourceAssetType() { + } + + /** + * Creates or finds a VectorStoreDataSourceAssetType from its string representation. + * + * @param name a name to look for. + * @return the corresponding VectorStoreDataSourceAssetType. + */ + @Generated + public static VectorStoreDataSourceAssetType fromString(String name) { + return fromString(name, VectorStoreDataSourceAssetType.class); + } + + /** + * Gets known VectorStoreDataSourceAssetType values. + * + * @return known VectorStoreDataSourceAssetType values. + */ + @Generated + public static Collection values() { + return values(VectorStoreDataSourceAssetType.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDeletionStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDeletionStatus.java new file mode 100644 index 000000000000..e6becbac03e6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreDeletionStatus.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response object for deleting a vector store. + */ +@Immutable +public final class VectorStoreDeletionStatus implements JsonSerializable { + + /* + * The ID of the resource specified for deletion. + */ + @Generated + private final String id; + + /* + * A value indicating whether deletion was successful. + */ + @Generated + private final boolean deleted; + + /* + * The object type, which is always 'vector_store.deleted'. + */ + @Generated + private final String object = "vector_store.deleted"; + + /** + * Creates an instance of VectorStoreDeletionStatus class. + * + * @param id the id value to set. + * @param deleted the deleted value to set. + */ + @Generated + private VectorStoreDeletionStatus(String id, boolean deleted) { + this.id = id; + this.deleted = deleted; + } + + /** + * Get the id property: The ID of the resource specified for deletion. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the deleted property: A value indicating whether deletion was successful. + * + * @return the deleted value. + */ + @Generated + public boolean isDeleted() { + return this.deleted; + } + + /** + * Get the object property: The object type, which is always 'vector_store.deleted'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeBooleanField("deleted", this.deleted); + jsonWriter.writeStringField("object", this.object); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreDeletionStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreDeletionStatus if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreDeletionStatus. + */ + @Generated + public static VectorStoreDeletionStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + boolean deleted = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("deleted".equals(fieldName)) { + deleted = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new VectorStoreDeletionStatus(id, deleted); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreExpirationPolicy.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreExpirationPolicy.java new file mode 100644 index 000000000000..3f9d94623648 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreExpirationPolicy.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The expiration policy for a vector store. + */ +@Immutable +public final class VectorStoreExpirationPolicy implements JsonSerializable { + + /* + * Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. + */ + @Generated + private final VectorStoreExpirationPolicyAnchor anchor; + + /* + * The anchor timestamp after which the expiration policy applies. + */ + @Generated + private final int days; + + /** + * Creates an instance of VectorStoreExpirationPolicy class. + * + * @param anchor the anchor value to set. + * @param days the days value to set. + */ + @Generated + public VectorStoreExpirationPolicy(VectorStoreExpirationPolicyAnchor anchor, int days) { + this.anchor = anchor; + this.days = days; + } + + /** + * Get the anchor property: Anchor timestamp after which the expiration policy applies. Supported anchors: + * `last_active_at`. + * + * @return the anchor value. + */ + @Generated + public VectorStoreExpirationPolicyAnchor getAnchor() { + return this.anchor; + } + + /** + * Get the days property: The anchor timestamp after which the expiration policy applies. + * + * @return the days value. + */ + @Generated + public int getDays() { + return this.days; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("anchor", this.anchor == null ? null : this.anchor.toString()); + jsonWriter.writeIntField("days", this.days); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreExpirationPolicy from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreExpirationPolicy if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreExpirationPolicy. + */ + @Generated + public static VectorStoreExpirationPolicy fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VectorStoreExpirationPolicyAnchor anchor = null; + int days = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("anchor".equals(fieldName)) { + anchor = VectorStoreExpirationPolicyAnchor.fromString(reader.getString()); + } else if ("days".equals(fieldName)) { + days = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new VectorStoreExpirationPolicy(anchor, days); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreExpirationPolicyAnchor.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreExpirationPolicyAnchor.java new file mode 100644 index 000000000000..52678813becf --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreExpirationPolicyAnchor.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Describes the relationship between the days and the expiration of this vector store. + */ +public final class VectorStoreExpirationPolicyAnchor extends ExpandableStringEnum { + + /** + * The expiration policy is based on the last time the vector store was active. + */ + @Generated + public static final VectorStoreExpirationPolicyAnchor LAST_ACTIVE_AT = fromString("last_active_at"); + + /** + * Creates a new instance of VectorStoreExpirationPolicyAnchor value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public VectorStoreExpirationPolicyAnchor() { + } + + /** + * Creates or finds a VectorStoreExpirationPolicyAnchor from its string representation. + * + * @param name a name to look for. + * @return the corresponding VectorStoreExpirationPolicyAnchor. + */ + @Generated + public static VectorStoreExpirationPolicyAnchor fromString(String name) { + return fromString(name, VectorStoreExpirationPolicyAnchor.class); + } + + /** + * Gets known VectorStoreExpirationPolicyAnchor values. + * + * @return known VectorStoreExpirationPolicyAnchor values. + */ + @Generated + public static Collection values() { + return values(VectorStoreExpirationPolicyAnchor.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFile.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFile.java new file mode 100644 index 000000000000..9df5760d1c75 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFile.java @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +/** + * Description of a file attached to a vector store. + */ +@Immutable +public final class VectorStoreFile implements JsonSerializable { + + /* + * The identifier, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The object type, which is always `vector_store.file`. + */ + @Generated + private final String object = "vector_store.file"; + + /* + * The total vector store usage in bytes. Note that this may be different from the original file + * size. + */ + @Generated + private final int usageBytes; + + /* + * The Unix timestamp (in seconds) for when the vector store file was created. + */ + @Generated + private final long createdAt; + + /* + * The ID of the vector store that the file is attached to. + */ + @Generated + private final String vectorStoreId; + + /* + * The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. + * The status `completed` indicates that the vector store file is ready for use. + */ + @Generated + private final VectorStoreFileStatus status; + + /* + * The last error associated with this vector store file. Will be `null` if there are no errors. + */ + @Generated + private final VectorStoreFileError lastError; + + /* + * The strategy used to chunk the file. + */ + @Generated + private final VectorStoreChunkingStrategyResponse chunkingStrategy; + + /** + * Creates an instance of VectorStoreFile class. + * + * @param id the id value to set. + * @param usageBytes the usageBytes value to set. + * @param createdAt the createdAt value to set. + * @param vectorStoreId the vectorStoreId value to set. + * @param status the status value to set. + * @param lastError the lastError value to set. + * @param chunkingStrategy the chunkingStrategy value to set. + */ + @Generated + private VectorStoreFile(String id, int usageBytes, OffsetDateTime createdAt, String vectorStoreId, + VectorStoreFileStatus status, VectorStoreFileError lastError, + VectorStoreChunkingStrategyResponse chunkingStrategy) { + this.id = id; + this.usageBytes = usageBytes; + if (createdAt == null) { + this.createdAt = 0L; + } else { + this.createdAt = createdAt.toEpochSecond(); + } + this.vectorStoreId = vectorStoreId; + this.status = status; + this.lastError = lastError; + this.chunkingStrategy = chunkingStrategy; + } + + /** + * Get the id property: The identifier, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the object property: The object type, which is always `vector_store.file`. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the usageBytes property: The total vector store usage in bytes. Note that this may be different from the + * original file + * size. + * + * @return the usageBytes value. + */ + @Generated + public int getUsageBytes() { + return this.usageBytes; + } + + /** + * Get the createdAt property: The Unix timestamp (in seconds) for when the vector store file was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC); + } + + /** + * Get the vectorStoreId property: The ID of the vector store that the file is attached to. + * + * @return the vectorStoreId value. + */ + @Generated + public String getVectorStoreId() { + return this.vectorStoreId; + } + + /** + * Get the status property: The status of the vector store file, which can be either `in_progress`, `completed`, + * `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. + * + * @return the status value. + */ + @Generated + public VectorStoreFileStatus getStatus() { + return this.status; + } + + /** + * Get the lastError property: The last error associated with this vector store file. Will be `null` if there are no + * errors. + * + * @return the lastError value. + */ + @Generated + public VectorStoreFileError getLastError() { + return this.lastError; + } + + /** + * Get the chunkingStrategy property: The strategy used to chunk the file. + * + * @return the chunkingStrategy value. + */ + @Generated + public VectorStoreChunkingStrategyResponse getChunkingStrategy() { + return this.chunkingStrategy; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeIntField("usage_bytes", this.usageBytes); + jsonWriter.writeLongField("created_at", this.createdAt); + jsonWriter.writeStringField("vector_store_id", this.vectorStoreId); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("last_error", this.lastError); + jsonWriter.writeJsonField("chunking_strategy", this.chunkingStrategy); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreFile from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreFile if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreFile. + */ + @Generated + public static VectorStoreFile fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + int usageBytes = 0; + OffsetDateTime createdAt = null; + String vectorStoreId = null; + VectorStoreFileStatus status = null; + VectorStoreFileError lastError = null; + VectorStoreChunkingStrategyResponse chunkingStrategy = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("usage_bytes".equals(fieldName)) { + usageBytes = reader.getInt(); + } else if ("created_at".equals(fieldName)) { + createdAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader.getLong()), ZoneOffset.UTC); + } else if ("vector_store_id".equals(fieldName)) { + vectorStoreId = reader.getString(); + } else if ("status".equals(fieldName)) { + status = VectorStoreFileStatus.fromString(reader.getString()); + } else if ("last_error".equals(fieldName)) { + lastError = VectorStoreFileError.fromJson(reader); + } else if ("chunking_strategy".equals(fieldName)) { + chunkingStrategy = VectorStoreChunkingStrategyResponse.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new VectorStoreFile(id, usageBytes, createdAt, vectorStoreId, status, lastError, chunkingStrategy); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileBatch.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileBatch.java new file mode 100644 index 000000000000..7ccf630421a4 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileBatch.java @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +/** + * A batch of files attached to a vector store. + */ +@Immutable +public final class VectorStoreFileBatch implements JsonSerializable { + + /* + * The identifier, which can be referenced in API endpoints. + */ + @Generated + private final String id; + + /* + * The object type, which is always `vector_store.file_batch`. + */ + @Generated + private final String object = "vector_store.files_batch"; + + /* + * The Unix timestamp (in seconds) for when the vector store files batch was created. + */ + @Generated + private final long createdAt; + + /* + * The ID of the vector store that the file is attached to. + */ + @Generated + private final String vectorStoreId; + + /* + * The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or + * `failed`. + */ + @Generated + private final VectorStoreFileBatchStatus status; + + /* + * Files count grouped by status processed or being processed by this vector store. + */ + @Generated + private final VectorStoreFileCount fileCounts; + + /** + * Creates an instance of VectorStoreFileBatch class. + * + * @param id the id value to set. + * @param createdAt the createdAt value to set. + * @param vectorStoreId the vectorStoreId value to set. + * @param status the status value to set. + * @param fileCounts the fileCounts value to set. + */ + @Generated + private VectorStoreFileBatch(String id, OffsetDateTime createdAt, String vectorStoreId, + VectorStoreFileBatchStatus status, VectorStoreFileCount fileCounts) { + this.id = id; + if (createdAt == null) { + this.createdAt = 0L; + } else { + this.createdAt = createdAt.toEpochSecond(); + } + this.vectorStoreId = vectorStoreId; + this.status = status; + this.fileCounts = fileCounts; + } + + /** + * Get the id property: The identifier, which can be referenced in API endpoints. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the object property: The object type, which is always `vector_store.file_batch`. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * Get the createdAt property: The Unix timestamp (in seconds) for when the vector store files batch was created. + * + * @return the createdAt value. + */ + @Generated + public OffsetDateTime getCreatedAt() { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.createdAt), ZoneOffset.UTC); + } + + /** + * Get the vectorStoreId property: The ID of the vector store that the file is attached to. + * + * @return the vectorStoreId value. + */ + @Generated + public String getVectorStoreId() { + return this.vectorStoreId; + } + + /** + * Get the status property: The status of the vector store files batch, which can be either `in_progress`, + * `completed`, `cancelled` or `failed`. + * + * @return the status value. + */ + @Generated + public VectorStoreFileBatchStatus getStatus() { + return this.status; + } + + /** + * Get the fileCounts property: Files count grouped by status processed or being processed by this vector store. + * + * @return the fileCounts value. + */ + @Generated + public VectorStoreFileCount getFileCounts() { + return this.fileCounts; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("object", this.object); + jsonWriter.writeLongField("created_at", this.createdAt); + jsonWriter.writeStringField("vector_store_id", this.vectorStoreId); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeJsonField("file_counts", this.fileCounts); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreFileBatch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreFileBatch if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreFileBatch. + */ + @Generated + public static VectorStoreFileBatch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + OffsetDateTime createdAt = null; + String vectorStoreId = null; + VectorStoreFileBatchStatus status = null; + VectorStoreFileCount fileCounts = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("created_at".equals(fieldName)) { + createdAt = OffsetDateTime.ofInstant(Instant.ofEpochSecond(reader.getLong()), ZoneOffset.UTC); + } else if ("vector_store_id".equals(fieldName)) { + vectorStoreId = reader.getString(); + } else if ("status".equals(fieldName)) { + status = VectorStoreFileBatchStatus.fromString(reader.getString()); + } else if ("file_counts".equals(fieldName)) { + fileCounts = VectorStoreFileCount.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new VectorStoreFileBatch(id, createdAt, vectorStoreId, status, fileCounts); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileBatchStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileBatchStatus.java new file mode 100644 index 000000000000..2cf3c10ad5a9 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileBatchStatus.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The status of the vector store file batch. + */ +public final class VectorStoreFileBatchStatus extends ExpandableStringEnum { + + /** + * The vector store is still processing this file batch. + */ + @Generated + public static final VectorStoreFileBatchStatus IN_PROGRESS = fromString("in_progress"); + + /** + * the vector store file batch is ready for use. + */ + @Generated + public static final VectorStoreFileBatchStatus COMPLETED = fromString("completed"); + + /** + * The vector store file batch was cancelled. + */ + @Generated + public static final VectorStoreFileBatchStatus CANCELLED = fromString("cancelled"); + + /** + * The vector store file batch failed to process. + */ + @Generated + public static final VectorStoreFileBatchStatus FAILED = fromString("failed"); + + /** + * Creates a new instance of VectorStoreFileBatchStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public VectorStoreFileBatchStatus() { + } + + /** + * Creates or finds a VectorStoreFileBatchStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding VectorStoreFileBatchStatus. + */ + @Generated + public static VectorStoreFileBatchStatus fromString(String name) { + return fromString(name, VectorStoreFileBatchStatus.class); + } + + /** + * Gets known VectorStoreFileBatchStatus values. + * + * @return known VectorStoreFileBatchStatus values. + */ + @Generated + public static Collection values() { + return values(VectorStoreFileBatchStatus.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileCount.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileCount.java new file mode 100644 index 000000000000..be68199edf66 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileCount.java @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Counts of files processed or being processed by this vector store grouped by status. + */ +@Immutable +public final class VectorStoreFileCount implements JsonSerializable { + + /* + * The number of files that are currently being processed. + */ + @Generated + private final int inProgress; + + /* + * The number of files that have been successfully processed. + */ + @Generated + private final int completed; + + /* + * The number of files that have failed to process. + */ + @Generated + private final int failed; + + /* + * The number of files that were cancelled. + */ + @Generated + private final int cancelled; + + /* + * The total number of files. + */ + @Generated + private final int total; + + /** + * Creates an instance of VectorStoreFileCount class. + * + * @param inProgress the inProgress value to set. + * @param completed the completed value to set. + * @param failed the failed value to set. + * @param cancelled the cancelled value to set. + * @param total the total value to set. + */ + @Generated + private VectorStoreFileCount(int inProgress, int completed, int failed, int cancelled, int total) { + this.inProgress = inProgress; + this.completed = completed; + this.failed = failed; + this.cancelled = cancelled; + this.total = total; + } + + /** + * Get the inProgress property: The number of files that are currently being processed. + * + * @return the inProgress value. + */ + @Generated + public int getInProgress() { + return this.inProgress; + } + + /** + * Get the completed property: The number of files that have been successfully processed. + * + * @return the completed value. + */ + @Generated + public int getCompleted() { + return this.completed; + } + + /** + * Get the failed property: The number of files that have failed to process. + * + * @return the failed value. + */ + @Generated + public int getFailed() { + return this.failed; + } + + /** + * Get the cancelled property: The number of files that were cancelled. + * + * @return the cancelled value. + */ + @Generated + public int getCancelled() { + return this.cancelled; + } + + /** + * Get the total property: The total number of files. + * + * @return the total value. + */ + @Generated + public int getTotal() { + return this.total; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("in_progress", this.inProgress); + jsonWriter.writeIntField("completed", this.completed); + jsonWriter.writeIntField("failed", this.failed); + jsonWriter.writeIntField("cancelled", this.cancelled); + jsonWriter.writeIntField("total", this.total); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreFileCount from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreFileCount if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreFileCount. + */ + @Generated + public static VectorStoreFileCount fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int inProgress = 0; + int completed = 0; + int failed = 0; + int cancelled = 0; + int total = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("in_progress".equals(fieldName)) { + inProgress = reader.getInt(); + } else if ("completed".equals(fieldName)) { + completed = reader.getInt(); + } else if ("failed".equals(fieldName)) { + failed = reader.getInt(); + } else if ("cancelled".equals(fieldName)) { + cancelled = reader.getInt(); + } else if ("total".equals(fieldName)) { + total = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new VectorStoreFileCount(inProgress, completed, failed, cancelled, total); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileDeletionStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileDeletionStatus.java new file mode 100644 index 000000000000..2023fe1f730f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileDeletionStatus.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Response object for deleting a vector store file relationship. + */ +@Immutable +public final class VectorStoreFileDeletionStatus implements JsonSerializable { + + /* + * The ID of the resource specified for deletion. + */ + @Generated + private final String id; + + /* + * A value indicating whether deletion was successful. + */ + @Generated + private final boolean deleted; + + /* + * The object type, which is always 'vector_store.deleted'. + */ + @Generated + private final String object = "vector_store.file.deleted"; + + /** + * Creates an instance of VectorStoreFileDeletionStatus class. + * + * @param id the id value to set. + * @param deleted the deleted value to set. + */ + @Generated + private VectorStoreFileDeletionStatus(String id, boolean deleted) { + this.id = id; + this.deleted = deleted; + } + + /** + * Get the id property: The ID of the resource specified for deletion. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the deleted property: A value indicating whether deletion was successful. + * + * @return the deleted value. + */ + @Generated + public boolean isDeleted() { + return this.deleted; + } + + /** + * Get the object property: The object type, which is always 'vector_store.deleted'. + * + * @return the object value. + */ + @Generated + public String getObject() { + return this.object; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeBooleanField("deleted", this.deleted); + jsonWriter.writeStringField("object", this.object); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreFileDeletionStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreFileDeletionStatus if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreFileDeletionStatus. + */ + @Generated + public static VectorStoreFileDeletionStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + boolean deleted = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("deleted".equals(fieldName)) { + deleted = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new VectorStoreFileDeletionStatus(id, deleted); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileError.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileError.java new file mode 100644 index 000000000000..eb29f40d8b2b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileError.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Details on the error that may have occurred while processing a file for this vector store. + */ +@Immutable +public final class VectorStoreFileError implements JsonSerializable { + + /* + * One of `server_error` or `rate_limit_exceeded`. + */ + @Generated + private final VectorStoreFileErrorCode code; + + /* + * A human-readable description of the error. + */ + @Generated + private final String message; + + /** + * Creates an instance of VectorStoreFileError class. + * + * @param code the code value to set. + * @param message the message value to set. + */ + @Generated + private VectorStoreFileError(VectorStoreFileErrorCode code, String message) { + this.code = code; + this.message = message; + } + + /** + * Get the code property: One of `server_error` or `rate_limit_exceeded`. + * + * @return the code value. + */ + @Generated + public VectorStoreFileErrorCode getCode() { + return this.code; + } + + /** + * Get the message property: A human-readable description of the error. + * + * @return the message value. + */ + @Generated + public String getMessage() { + return this.message; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("code", this.code == null ? null : this.code.toString()); + jsonWriter.writeStringField("message", this.message); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreFileError from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreFileError if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreFileError. + */ + @Generated + public static VectorStoreFileError fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VectorStoreFileErrorCode code = null; + String message = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("code".equals(fieldName)) { + code = VectorStoreFileErrorCode.fromString(reader.getString()); + } else if ("message".equals(fieldName)) { + message = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new VectorStoreFileError(code, message); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileErrorCode.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileErrorCode.java new file mode 100644 index 000000000000..7ead286393c8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileErrorCode.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Error code variants for vector store file processing. + */ +public final class VectorStoreFileErrorCode extends ExpandableStringEnum { + + /** + * An server error occurred. + */ + @Generated + public static final VectorStoreFileErrorCode SERVER_ERROR = fromString("server_error"); + + /** + * The file is not valid. + */ + @Generated + public static final VectorStoreFileErrorCode INVALID_FILE = fromString("invalid_file"); + + /** + * The file is of unsupported type. + */ + @Generated + public static final VectorStoreFileErrorCode UNSUPPORTED_FILE = fromString("unsupported_file"); + + /** + * Creates a new instance of VectorStoreFileErrorCode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public VectorStoreFileErrorCode() { + } + + /** + * Creates or finds a VectorStoreFileErrorCode from its string representation. + * + * @param name a name to look for. + * @return the corresponding VectorStoreFileErrorCode. + */ + @Generated + public static VectorStoreFileErrorCode fromString(String name) { + return fromString(name, VectorStoreFileErrorCode.class); + } + + /** + * Gets known VectorStoreFileErrorCode values. + * + * @return known VectorStoreFileErrorCode values. + */ + @Generated + public static Collection values() { + return values(VectorStoreFileErrorCode.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileStatus.java new file mode 100644 index 000000000000..056486ad8c36 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileStatus.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Vector store file status. + */ +public final class VectorStoreFileStatus extends ExpandableStringEnum { + + /** + * The file is currently being processed. + */ + @Generated + public static final VectorStoreFileStatus IN_PROGRESS = fromString("in_progress"); + + /** + * The file has been successfully processed. + */ + @Generated + public static final VectorStoreFileStatus COMPLETED = fromString("completed"); + + /** + * The file has failed to process. + */ + @Generated + public static final VectorStoreFileStatus FAILED = fromString("failed"); + + /** + * The file was cancelled. + */ + @Generated + public static final VectorStoreFileStatus CANCELLED = fromString("cancelled"); + + /** + * Creates a new instance of VectorStoreFileStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public VectorStoreFileStatus() { + } + + /** + * Creates or finds a VectorStoreFileStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding VectorStoreFileStatus. + */ + @Generated + public static VectorStoreFileStatus fromString(String name) { + return fromString(name, VectorStoreFileStatus.class); + } + + /** + * Gets known VectorStoreFileStatus values. + * + * @return known VectorStoreFileStatus values. + */ + @Generated + public static Collection values() { + return values(VectorStoreFileStatus.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileStatusFilter.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileStatusFilter.java new file mode 100644 index 000000000000..f0c073a9e25f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreFileStatusFilter.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Query parameter filter for vector store file retrieval endpoint. + */ +public final class VectorStoreFileStatusFilter extends ExpandableStringEnum { + + /** + * Retrieve only files that are currently being processed. + */ + @Generated + public static final VectorStoreFileStatusFilter IN_PROGRESS = fromString("in_progress"); + + /** + * Retrieve only files that have been successfully processed. + */ + @Generated + public static final VectorStoreFileStatusFilter COMPLETED = fromString("completed"); + + /** + * Retrieve only files that have failed to process. + */ + @Generated + public static final VectorStoreFileStatusFilter FAILED = fromString("failed"); + + /** + * Retrieve only files that were cancelled. + */ + @Generated + public static final VectorStoreFileStatusFilter CANCELLED = fromString("cancelled"); + + /** + * Creates a new instance of VectorStoreFileStatusFilter value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public VectorStoreFileStatusFilter() { + } + + /** + * Creates or finds a VectorStoreFileStatusFilter from its string representation. + * + * @param name a name to look for. + * @return the corresponding VectorStoreFileStatusFilter. + */ + @Generated + public static VectorStoreFileStatusFilter fromString(String name) { + return fromString(name, VectorStoreFileStatusFilter.class); + } + + /** + * Gets known VectorStoreFileStatusFilter values. + * + * @return known VectorStoreFileStatusFilter values. + */ + @Generated + public static Collection values() { + return values(VectorStoreFileStatusFilter.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyOptions.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyOptions.java new file mode 100644 index 000000000000..182db1c68f85 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyOptions.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Options to configure a vector store static chunking strategy. + */ +@Immutable +public final class VectorStoreStaticChunkingStrategyOptions + implements JsonSerializable { + + /* + * The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum + * value is 4096. + */ + @Generated + private final int maxChunkSizeTokens; + + /* + * The number of tokens that overlap between chunks. The default value is 400. + * Note that the overlap must not exceed half of max_chunk_size_tokens. + */ + @Generated + private final int chunkOverlapTokens; + + /** + * Creates an instance of VectorStoreStaticChunkingStrategyOptions class. + * + * @param maxChunkSizeTokens the maxChunkSizeTokens value to set. + * @param chunkOverlapTokens the chunkOverlapTokens value to set. + */ + @Generated + public VectorStoreStaticChunkingStrategyOptions(int maxChunkSizeTokens, int chunkOverlapTokens) { + this.maxChunkSizeTokens = maxChunkSizeTokens; + this.chunkOverlapTokens = chunkOverlapTokens; + } + + /** + * Get the maxChunkSizeTokens property: The maximum number of tokens in each chunk. The default value is 800. The + * minimum value is 100 and the maximum value is 4096. + * + * @return the maxChunkSizeTokens value. + */ + @Generated + public int getMaxChunkSizeTokens() { + return this.maxChunkSizeTokens; + } + + /** + * Get the chunkOverlapTokens property: The number of tokens that overlap between chunks. The default value is 400. + * Note that the overlap must not exceed half of max_chunk_size_tokens. + * + * @return the chunkOverlapTokens value. + */ + @Generated + public int getChunkOverlapTokens() { + return this.chunkOverlapTokens; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("max_chunk_size_tokens", this.maxChunkSizeTokens); + jsonWriter.writeIntField("chunk_overlap_tokens", this.chunkOverlapTokens); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreStaticChunkingStrategyOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreStaticChunkingStrategyOptions if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreStaticChunkingStrategyOptions. + */ + @Generated + public static VectorStoreStaticChunkingStrategyOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int maxChunkSizeTokens = 0; + int chunkOverlapTokens = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("max_chunk_size_tokens".equals(fieldName)) { + maxChunkSizeTokens = reader.getInt(); + } else if ("chunk_overlap_tokens".equals(fieldName)) { + chunkOverlapTokens = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new VectorStoreStaticChunkingStrategyOptions(maxChunkSizeTokens, chunkOverlapTokens); + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyRequest.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyRequest.java new file mode 100644 index 000000000000..8bd0eddfff09 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyRequest.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A statically configured chunking strategy. + */ +@Immutable +public final class VectorStoreStaticChunkingStrategyRequest extends VectorStoreChunkingStrategyRequest { + + /* + * The object type. + */ + @Generated + private VectorStoreChunkingStrategyRequestType type = VectorStoreChunkingStrategyRequestType.STATIC; + + /* + * The options for the static chunking strategy. + */ + @Generated + private final VectorStoreStaticChunkingStrategyOptions staticProperty; + + /** + * Creates an instance of VectorStoreStaticChunkingStrategyRequest class. + * + * @param staticProperty the staticProperty value to set. + */ + @Generated + public VectorStoreStaticChunkingStrategyRequest(VectorStoreStaticChunkingStrategyOptions staticProperty) { + this.staticProperty = staticProperty; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public VectorStoreChunkingStrategyRequestType getType() { + return this.type; + } + + /** + * Get the staticProperty property: The options for the static chunking strategy. + * + * @return the staticProperty value. + */ + @Generated + public VectorStoreStaticChunkingStrategyOptions getStaticProperty() { + return this.staticProperty; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("static", this.staticProperty); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreStaticChunkingStrategyRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreStaticChunkingStrategyRequest if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreStaticChunkingStrategyRequest. + */ + @Generated + public static VectorStoreStaticChunkingStrategyRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VectorStoreStaticChunkingStrategyOptions staticProperty = null; + VectorStoreChunkingStrategyRequestType type = VectorStoreChunkingStrategyRequestType.STATIC; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("static".equals(fieldName)) { + staticProperty = VectorStoreStaticChunkingStrategyOptions.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = VectorStoreChunkingStrategyRequestType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + VectorStoreStaticChunkingStrategyRequest deserializedVectorStoreStaticChunkingStrategyRequest + = new VectorStoreStaticChunkingStrategyRequest(staticProperty); + deserializedVectorStoreStaticChunkingStrategyRequest.type = type; + return deserializedVectorStoreStaticChunkingStrategyRequest; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyResponse.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyResponse.java new file mode 100644 index 000000000000..d721efc1df51 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStaticChunkingStrategyResponse.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A statically configured chunking strategy. + */ +@Immutable +public final class VectorStoreStaticChunkingStrategyResponse extends VectorStoreChunkingStrategyResponse { + + /* + * The object type. + */ + @Generated + private VectorStoreChunkingStrategyResponseType type = VectorStoreChunkingStrategyResponseType.STATIC; + + /* + * The options for the static chunking strategy. + */ + @Generated + private final VectorStoreStaticChunkingStrategyOptions staticProperty; + + /** + * Creates an instance of VectorStoreStaticChunkingStrategyResponse class. + * + * @param staticProperty the staticProperty value to set. + */ + @Generated + private VectorStoreStaticChunkingStrategyResponse(VectorStoreStaticChunkingStrategyOptions staticProperty) { + this.staticProperty = staticProperty; + } + + /** + * Get the type property: The object type. + * + * @return the type value. + */ + @Generated + @Override + public VectorStoreChunkingStrategyResponseType getType() { + return this.type; + } + + /** + * Get the staticProperty property: The options for the static chunking strategy. + * + * @return the staticProperty value. + */ + @Generated + public VectorStoreStaticChunkingStrategyOptions getStaticProperty() { + return this.staticProperty; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("static", this.staticProperty); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VectorStoreStaticChunkingStrategyResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VectorStoreStaticChunkingStrategyResponse if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VectorStoreStaticChunkingStrategyResponse. + */ + @Generated + public static VectorStoreStaticChunkingStrategyResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VectorStoreStaticChunkingStrategyOptions staticProperty = null; + VectorStoreChunkingStrategyResponseType type = VectorStoreChunkingStrategyResponseType.STATIC; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + if ("static".equals(fieldName)) { + staticProperty = VectorStoreStaticChunkingStrategyOptions.fromJson(reader); + } else if ("type".equals(fieldName)) { + type = VectorStoreChunkingStrategyResponseType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + VectorStoreStaticChunkingStrategyResponse deserializedVectorStoreStaticChunkingStrategyResponse + = new VectorStoreStaticChunkingStrategyResponse(staticProperty); + deserializedVectorStoreStaticChunkingStrategyResponse.type = type; + return deserializedVectorStoreStaticChunkingStrategyResponse; + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStatus.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStatus.java new file mode 100644 index 000000000000..3ae3cf9277d4 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/VectorStoreStatus.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +package com.azure.ai.agents.persistent.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Vector store possible status. + */ +public final class VectorStoreStatus extends ExpandableStringEnum { + + /** + * expired status indicates that this vector store has expired and is no longer available for use. + */ + @Generated + public static final VectorStoreStatus EXPIRED = fromString("expired"); + + /** + * in_progress status indicates that this vector store is still processing files. + */ + @Generated + public static final VectorStoreStatus IN_PROGRESS = fromString("in_progress"); + + /** + * completed status indicates that this vector store is ready for use. + */ + @Generated + public static final VectorStoreStatus COMPLETED = fromString("completed"); + + /** + * Creates a new instance of VectorStoreStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public VectorStoreStatus() { + } + + /** + * Creates or finds a VectorStoreStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding VectorStoreStatus. + */ + @Generated + public static VectorStoreStatus fromString(String name) { + return fromString(name, VectorStoreStatus.class); + } + + /** + * Gets known VectorStoreStatus values. + * + * @return known VectorStoreStatus values. + */ + @Generated + public static Collection values() { + return values(VectorStoreStatus.class); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/package-info.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/package-info.java new file mode 100644 index 000000000000..0cb1af4b208b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +/** + * + * Package containing the data models for Agents. + * + */ +package com.azure.ai.agents.persistent.models; diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/PersistentAgentServerSentEvents.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/PersistentAgentServerSentEvents.java new file mode 100644 index 000000000000..cfa7772c4199 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/PersistentAgentServerSentEvents.java @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent.models.streaming; + +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import reactor.core.publisher.Flux; +import reactor.core.scheduler.Schedulers; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.DONE; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.ERROR; + +/** + * A class that handles the deserialization of server sent events. + */ +public final class PersistentAgentServerSentEvents { + + // Server sent events are divided by 2 CRLF or single LF character + private static final int SSE_CHUNK_LINE_BREAK_COUNT_MARKER = 2; + + private final ClientLogger logger = new ClientLogger(PersistentAgentServerSentEvents.class); + + /** + * A factory that determines into which type to deserialize the server sent events. + */ + private final StreamTypeFactory eventDeserializer = new StreamTypeFactory(); + + /** + * The source of the server sent events. + */ + private final Flux source; + + /** + * The output stream accumulating the server sent events. + */ + private ByteArrayOutputStream outStream; + + /** + * Creates a new instance of PersistentAgentServerSentEvents. + * + * @param source The source of the server sent events. + */ + public PersistentAgentServerSentEvents(Flux source) { + this.source = source; + this.outStream = new ByteArrayOutputStream(); + } + + /** + * Gets the stream of server sent events. + * + * @return A stream of server sent events. + */ + public Flux getEvents() { + return mapEventStream(); + } + + /** + * Maps the byte buffer to a stream of server sent events. + * + * @return A stream of server sent events deserialized into StreamUpdates. + */ + private Flux mapEventStream() { + return source.publishOn(Schedulers.boundedElastic()).concatMap(byteBuffer -> { + List values = new ArrayList<>(); + byte[] byteArray = FluxUtil.byteBufferToArray(byteBuffer); + + byte[] outByteArray = outStream.toByteArray(); + int lineBreakCharsEncountered + = outByteArray.length > 0 && isByteLineFeed(outByteArray[outByteArray.length - 1]) ? 1 : 0; + + int startIndex = 0; + for (int i = 0; i < byteArray.length; i++) { + byte currentByte = byteArray[i]; + if (isByteLineFeed(currentByte)) { + lineBreakCharsEncountered++; + + // 2 line breaks signify the end of a server sent event. + if (lineBreakCharsEncountered == SSE_CHUNK_LINE_BREAK_COUNT_MARKER) { + outStream.write(byteArray, startIndex, i - startIndex + 1); + + String currentLine; + try { + currentLine = outStream.toString(StandardCharsets.UTF_8.name()); + handleCurrentEvent(currentLine, values); + } catch (IOException e) { + return Flux.error(e); + } + outStream = new ByteArrayOutputStream(); + startIndex = i + 1; + } + } else { + // In some cases line breaks can contain both the line feed and carriage return characters. + // We don't want to reset the line break count if we encounter a carriage return character. + // We are assuming that line feeds and carriage returns, if both present, are always paired. + // With this assumption, we are able to operate when carriage returns aren't present in the input also. + if (!isByteCarriageReturn(currentByte)) { + lineBreakCharsEncountered = 0; + } + } + } + + if (startIndex < byteArray.length) { + outStream.write(byteArray, startIndex, byteArray.length - startIndex); + } + + try { + String remainingBytes = outStream.toString(StandardCharsets.UTF_8.name()); + // If this is in fact, the last event, it will be appropriately chunked. Otherwise, we will cache and + // try again in the next byte buffer with a fuller event. + if (remainingBytes.endsWith("\n\n") || remainingBytes.endsWith("\r\n\r\n")) { + handleCurrentEvent(remainingBytes, values); + } + } catch (IllegalArgumentException | UncheckedIOException e) { + // UncheckedIOException is thrown when we attempt to deserialize incomplete JSON + // Even split across different ByteBuffers, the next one will contain the rest of the event. + return Flux.fromIterable(values); + } catch (IOException e) { + return Flux.error(e); + } + return Flux.fromIterable(values); + }).cache(); + } + + /** + * Determines if character is a line feed (0xA). + * + * @param character The character to check. + * @return True if character is a line feed character, false otherwise. + */ + private boolean isByteLineFeed(byte character) { + return character == 0xA; + } + + /** + * Determines if character is a carriage return (0xD). + * + * @param character The character to check. + * @return True if character is a carriage return character, false otherwise. + */ + private boolean isByteCarriageReturn(byte character) { + return character == 0xD; + } + + /** + * Handles a collected event from the byte buffer which is formated as a UTF_8 string. + * + * @param currentEvent The current line of the server sent event. + * @param outputValues The list of values to add the current line to. + * @throws IllegalStateException If the current event contains a server side error. + * @throws IllegalArgumentException If there's an error processing the event data. + * @throws UncheckedIOException If there's an error deserializing the event data. + */ + public void handleCurrentEvent(String currentEvent, List outputValues) + throws IllegalArgumentException { + if (currentEvent.isEmpty()) { + return; + } + + // We split the event into the event name and the event data. We don't want to split on \n in the data body. + String[] lines = currentEvent.split("\n", 2); + + if (lines.length != 2) { + return; + } + + if (lines[0].isEmpty() || lines[1].isEmpty()) { + return; + } + + String[] eventParts = lines[0].split(":", 2); + String[] dataParts = lines[1].split(":", 2); + + if (eventParts.length != 2 || !eventParts[0].trim().equals("event")) { + throw logger.logExceptionAsError(new IllegalArgumentException("Invalid event format: missing event name")); + } + String eventName = eventParts[1].trim(); + + if (dataParts.length != 2 || !dataParts[0].trim().equals("data")) { + throw logger.logExceptionAsError(new IllegalArgumentException("Invalid event format: missing event data")); + } + String eventJson = dataParts[1].trim(); + + if (DONE.equals(PersistentAgentStreamEvent.fromString(eventName))) { + return; + } + if (ERROR.equals(PersistentAgentStreamEvent.fromString(eventName))) { + throw logger.logExceptionAsError(new IllegalArgumentException(eventJson)); + } + + outputValues.add(this.eventDeserializer.deserializeEvent(eventName, BinaryData.fromString(eventJson))); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageCreation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageCreation.java new file mode 100644 index 000000000000..798cb50877b0 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageCreation.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent.models.streaming; + +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.ai.agents.persistent.models.ThreadMessage; + +/** + * Represents a stream update indicating a message state change, e.g. creation, completion, etc. + */ +public final class StreamMessageCreation extends StreamUpdate { + + /** + * The stream update with the data about this message sent by the service. + */ + private final ThreadMessage message; + + /** + * Creates a new instance of StreamMessageCreation. + * + * @param threadMessage The {@link ThreadMessage} with the data about this message sent by the service. + * @param kind The stream event type associated with this update. + */ + public StreamMessageCreation(ThreadMessage threadMessage, PersistentAgentStreamEvent kind) { + super(kind); + this.message = threadMessage; + } + + /** + * Get the data of this message sent by the service. + * + * @return the update with the data about this message sent by the service. + */ + public ThreadMessage getMessage() { + return message; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageUpdate.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageUpdate.java new file mode 100644 index 000000000000..8d18ce3b189a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageUpdate.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent.models.streaming; + +import com.azure.ai.agents.persistent.models.MessageDeltaChunk; +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; + +/** + * Represents a stream event indicating an incremental service message update. + */ +public class StreamMessageUpdate extends StreamUpdate { + /** + * The message incremental delta update sent by the service. + */ + private final MessageDeltaChunk message; + + /** + * Creates a new instance of StreamMessageUpdate. + * + * @param messageDelta The {@link MessageDeltaChunk} with the incremental delta update sent by the service. + * @param kind The stream event type associated with this update. + */ + public StreamMessageUpdate(MessageDeltaChunk messageDelta, PersistentAgentStreamEvent kind) { + super(kind); + this.message = messageDelta; + } + + /** + * Get the message incremental delta update sent by the service. + * + * @return the message incremental delta update sent by the service. + */ + public MessageDeltaChunk getMessage() { + return message; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRequiredAction.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRequiredAction.java new file mode 100644 index 000000000000..fe73471d7edb --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRequiredAction.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent.models.streaming; + +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.ai.agents.persistent.models.ThreadRun; + +/** + * Represents a stream update indicating that input from the user is required. + */ +public class StreamRequiredAction extends StreamUpdate { + + /** + * The message detailing the action required by the service. + */ + private final ThreadRun message; + + /** + * Creates a new instance of StreamRequiredAction. + * + * @param action The {@link ThreadRun} with the action required by the service. + * @param kind The stream event type associated with this update. + */ + public StreamRequiredAction(ThreadRun action, PersistentAgentStreamEvent kind) { + super(kind); + this.message = action; + } + + /** + * Get the message detailing the action required by the service. + * + * @return the message detailing the action required by the service. + */ + public ThreadRun getMessage() { + return message; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunCreation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunCreation.java new file mode 100644 index 000000000000..60fca64b2a98 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunCreation.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent.models.streaming; + +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.ai.agents.persistent.models.RunStep; + +/** + * Represents a stream update indicating a change of state in a run step, e.g. creation, completion, etc. + */ +public class StreamRunCreation extends StreamUpdate { + /** + * The update with the data about this run step sent by the service. + */ + private final RunStep message; + + /** + * Creates a new instance of StreamRunCreation. + * + * @param run The {@link RunStep} with the data about this run step sent by the service. + * @param kind The stream event type associated with this update. + */ + public StreamRunCreation(RunStep run, PersistentAgentStreamEvent kind) { + super(kind); + this.message = run; + } + + /** + * Get the update with the data about this run step sent by the service. + * + * @return the update with the data about this run step sent by the service. + */ + public RunStep getMessage() { + return message; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunStepUpdate.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunStepUpdate.java new file mode 100644 index 000000000000..1896ecc637a7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunStepUpdate.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent.models.streaming; + +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.ai.agents.persistent.models.RunStepDeltaChunk; + +/** + * Represents a stream update indicating a change of state in a run step, e.g. creation, completion, etc. + */ +public class StreamRunStepUpdate extends StreamUpdate { + + /** + * The incremental update sent by the service. + */ + private final RunStepDeltaChunk message; + + /** + * Creates a new instance of StreamRunStepUpdate. + * + * @param runStepDelta The {@link RunStepDeltaChunk} with the update sent by the service. + * @param kind The stream event type associated with this update. + */ + public StreamRunStepUpdate(RunStepDeltaChunk runStepDelta, PersistentAgentStreamEvent kind) { + super(kind); + this.message = runStepDelta; + } + + /** + * Get the incremental update sent by the service. + * + * @return the incremental update sent by the service. + */ + public RunStepDeltaChunk getMessage() { + return message; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadCreation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadCreation.java new file mode 100644 index 000000000000..3a9019fad359 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadCreation.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent.models.streaming; + +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; + +/** + * Represents a stream update that indicating the creation of a new thread. + */ +public final class StreamThreadCreation extends StreamUpdate { + + /** + * The thread data sent in the update by the service. + */ + private final PersistentAgentStreamEvent message; + + /** + * Creates a new instance of StreamThreadCreation. + * + * @param thread The {@link PersistentAgentStreamEvent} in the update sent by the service. + * @param kind The stream event type associated with this update. + */ + public StreamThreadCreation(PersistentAgentStreamEvent thread, PersistentAgentStreamEvent kind) { + super(kind); + this.message = thread; + } + + /** + * Get the thread data sent in the update by the service. + * + * @return the thread data sent in the update by the service. + */ + public PersistentAgentStreamEvent getMessage() { + return message; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadRunCreation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadRunCreation.java new file mode 100644 index 000000000000..ba6f9f9d3826 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadRunCreation.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent.models.streaming; + +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.ai.agents.persistent.models.ThreadRun; + +/** + * Represents a stream update indicating a change of state in a thread run, e.g. creation, completion, etc. + */ +public final class StreamThreadRunCreation extends StreamUpdate { + + /** + * The thread run with the update sent by the service. + */ + private final ThreadRun message; + + /** + * Creates a new instance of StreamThreadRunCreation. + * + * @param threadRun The {@link ThreadRun} with the update sent by the service. + * @param kind The stream event type associated with this update. + */ + public StreamThreadRunCreation(ThreadRun threadRun, PersistentAgentStreamEvent kind) { + super(kind); + this.message = threadRun; + } + + /** + * Get the thread run with the update sent by the service. + * + * @return the thread run with the update sent by the service. + */ + public ThreadRun getMessage() { + return message; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamTypeFactory.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamTypeFactory.java new file mode 100644 index 000000000000..ffe5b0ca6ba9 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamTypeFactory.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent.models.streaming; + +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.ai.agents.persistent.models.MessageDeltaChunk; +import com.azure.ai.agents.persistent.models.RunStep; +import com.azure.ai.agents.persistent.models.RunStepDeltaChunk; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; + +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_CREATED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_MESSAGE_COMPLETED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_MESSAGE_CREATED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_MESSAGE_DELTA; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_MESSAGE_INCOMPLETE; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_MESSAGE_IN_PROGRESS; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_CANCELLED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_CANCELLING; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_COMPLETED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_CREATED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_EXPIRED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_FAILED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_IN_PROGRESS; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_QUEUED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_REQUIRES_ACTION; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_STEP_CANCELLED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_STEP_COMPLETED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_STEP_CREATED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_STEP_DELTA; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_STEP_EXPIRED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_STEP_FAILED; +import static com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent.THREAD_RUN_STEP_IN_PROGRESS; + +/** + * Deserializes the server sent event into the appropriate type. Which subtype of {@link StreamUpdate} is used, is + * determined by the event {@link PersistentAgentStreamEvent}. The subtype is merely a wrapper around the actual deserialized + * data. + */ +public final class StreamTypeFactory { + private final ClientLogger logger = new ClientLogger(StreamTypeFactory.class); + + /** + * Default constructor for creating a new instance of StreamTypeFactory. + */ + public StreamTypeFactory() { + // Default constructor + } + + /** + * Deserializes the server sent event into the appropriate type. + * + * @param eventName The name of the event. + * @param eventJson The event data. + * @return The deserialized event. + * @throws IllegalArgumentException If the event type is unknown. + */ + public StreamUpdate deserializeEvent(String eventName, BinaryData eventJson) throws IllegalArgumentException { + PersistentAgentStreamEvent event = PersistentAgentStreamEvent.fromString(eventName); + + if (THREAD_CREATED.equals(event)) { + return new StreamThreadCreation(eventJson.toObject(PersistentAgentStreamEvent.class), event); + } else if (THREAD_RUN_CREATED.equals(event) + || THREAD_RUN_QUEUED.equals(event) + || THREAD_RUN_IN_PROGRESS.equals(event) + || THREAD_RUN_COMPLETED.equals(event) + || THREAD_RUN_CANCELLED.equals(event) + || THREAD_RUN_CANCELLING.equals(event) + || THREAD_RUN_FAILED.equals(event) + || THREAD_RUN_EXPIRED.equals(event)) { + return new StreamThreadRunCreation(eventJson.toObject(ThreadRun.class), event); + } else if (THREAD_RUN_STEP_CREATED.equals(event) + || THREAD_RUN_STEP_IN_PROGRESS.equals(event) + || THREAD_RUN_STEP_COMPLETED.equals(event) + || THREAD_RUN_STEP_FAILED.equals(event) + || THREAD_RUN_STEP_CANCELLED.equals(event) + || THREAD_RUN_STEP_EXPIRED.equals(event)) { + return new StreamRunCreation(eventJson.toObject(RunStep.class), event); + } else if (THREAD_MESSAGE_CREATED.equals(event) + || THREAD_MESSAGE_IN_PROGRESS.equals(event) + || THREAD_MESSAGE_COMPLETED.equals(event) + || THREAD_MESSAGE_INCOMPLETE.equals(event)) { + return new StreamMessageCreation(eventJson.toObject(ThreadMessage.class), event); + } else if (THREAD_MESSAGE_DELTA.equals(event)) { + return new StreamMessageUpdate(eventJson.toObject(MessageDeltaChunk.class), event); + } else if (THREAD_RUN_STEP_DELTA.equals(event)) { + return new StreamRunStepUpdate(eventJson.toObject(RunStepDeltaChunk.class), event); + } else if (THREAD_RUN_REQUIRES_ACTION.equals(event)) { + return new StreamRequiredAction(eventJson.toObject(ThreadRun.class), event); + } else { + throw logger.logExceptionAsError(new IllegalArgumentException("Unknown event type: " + event)); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamUpdate.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamUpdate.java new file mode 100644 index 000000000000..35f415a8c417 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamUpdate.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent.models.streaming; + +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; + +/** + * Parent class for all stream updates types. + */ +public abstract class StreamUpdate { + + /** + * The kind of stream update. This can take any value of the {@link PersistentAgentStreamEvent} enum. + */ + private final PersistentAgentStreamEvent kind; + + /** + * We always want to know to which {@link PersistentAgentStreamEvent} this StreamUpdate is associated, therefore we enforce + * any deriving class to supply it upon construction of a new instance. + * + * @param kind The kind of stream update. + */ + public StreamUpdate(PersistentAgentStreamEvent kind) { + this.kind = kind; + } + + /** + * Returns what kind of StreamUpdate this is. See {@link PersistentAgentStreamEvent} for possible values. + * + * @return the kind of stream update. + */ + public PersistentAgentStreamEvent getKind() { + return kind; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/package-info.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/package-info.java new file mode 100644 index 000000000000..ef6818a6402b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package containing classes for handling streaming updates from AI Project services. + * This package provides models for different types of stream events and updates. + */ +package com.azure.ai.agents.persistent.models.streaming; diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/package-info.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/package-info.java new file mode 100644 index 000000000000..503827815888 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. +/** + * + * Package containing the classes for Agents. + * + */ +package com.azure.ai.agents.persistent; diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/module-info.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/module-info.java new file mode 100644 index 000000000000..d4397c7e4f66 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/module-info.java @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.ai.agents.persistent { + requires transitive com.azure.core; + + exports com.azure.ai.agents.persistent; + exports com.azure.ai.agents.persistent.models; + exports com.azure.ai.agents.persistent.models.streaming; + + opens com.azure.ai.agents.persistent.implementation.models to com.azure.core; + opens com.azure.ai.agents.persistent.models to com.azure.core; + opens com.azure.ai.agents.persistent.models.streaming to com.azure.core; +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/resources/META-INF/azure-ai-agents-persistent_apiview_properties.json b/sdk/ai/azure-ai-agents-persistent/src/main/resources/META-INF/azure-ai-agents-persistent_apiview_properties.json new file mode 100644 index 000000000000..435c19c8a182 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/resources/META-INF/azure-ai-agents-persistent_apiview_properties.json @@ -0,0 +1,390 @@ +{ + "flavor": "azure", + "CrossLanguageDefinitionId": { + "com.azure.ai.agents.persistent.FilesAsyncClient": "Azure.AI.Agents.Files", + "com.azure.ai.agents.persistent.FilesAsyncClient.deleteFile": "Azure.AI.Agents.Files.deleteFile", + "com.azure.ai.agents.persistent.FilesAsyncClient.deleteFileWithResponse": "Azure.AI.Agents.Files.deleteFile", + "com.azure.ai.agents.persistent.FilesAsyncClient.getFile": "Azure.AI.Agents.Files.getFile", + "com.azure.ai.agents.persistent.FilesAsyncClient.getFileContent": "Azure.AI.Agents.Files.getFileContent", + "com.azure.ai.agents.persistent.FilesAsyncClient.getFileContentWithResponse": "Azure.AI.Agents.Files.getFileContent", + "com.azure.ai.agents.persistent.FilesAsyncClient.getFileWithResponse": "Azure.AI.Agents.Files.getFile", + "com.azure.ai.agents.persistent.FilesAsyncClient.listFiles": "Azure.AI.Agents.Files.listFiles", + "com.azure.ai.agents.persistent.FilesAsyncClient.listFilesWithResponse": "Azure.AI.Agents.Files.listFiles", + "com.azure.ai.agents.persistent.FilesAsyncClient.uploadFile": "Azure.AI.Agents.Files.uploadFile", + "com.azure.ai.agents.persistent.FilesAsyncClient.uploadFileWithResponse": "Azure.AI.Agents.Files.uploadFile", + "com.azure.ai.agents.persistent.FilesClient": "Azure.AI.Agents.Files", + "com.azure.ai.agents.persistent.FilesClient.deleteFile": "Azure.AI.Agents.Files.deleteFile", + "com.azure.ai.agents.persistent.FilesClient.deleteFileWithResponse": "Azure.AI.Agents.Files.deleteFile", + "com.azure.ai.agents.persistent.FilesClient.getFile": "Azure.AI.Agents.Files.getFile", + "com.azure.ai.agents.persistent.FilesClient.getFileContent": "Azure.AI.Agents.Files.getFileContent", + "com.azure.ai.agents.persistent.FilesClient.getFileContentWithResponse": "Azure.AI.Agents.Files.getFileContent", + "com.azure.ai.agents.persistent.FilesClient.getFileWithResponse": "Azure.AI.Agents.Files.getFile", + "com.azure.ai.agents.persistent.FilesClient.listFiles": "Azure.AI.Agents.Files.listFiles", + "com.azure.ai.agents.persistent.FilesClient.listFilesWithResponse": "Azure.AI.Agents.Files.listFiles", + "com.azure.ai.agents.persistent.FilesClient.uploadFile": "Azure.AI.Agents.Files.uploadFile", + "com.azure.ai.agents.persistent.FilesClient.uploadFileWithResponse": "Azure.AI.Agents.Files.uploadFile", + "com.azure.ai.agents.persistent.MessagesAsyncClient": "Azure.AI.Agents.Messages", + "com.azure.ai.agents.persistent.MessagesAsyncClient.createMessage": "Azure.AI.Agents.Messages.createMessage", + "com.azure.ai.agents.persistent.MessagesAsyncClient.createMessageWithResponse": "Azure.AI.Agents.Messages.createMessage", + "com.azure.ai.agents.persistent.MessagesAsyncClient.getMessage": "Azure.AI.Agents.Messages.getMessage", + "com.azure.ai.agents.persistent.MessagesAsyncClient.getMessageWithResponse": "Azure.AI.Agents.Messages.getMessage", + "com.azure.ai.agents.persistent.MessagesAsyncClient.listMessages": "Azure.AI.Agents.Messages.listMessages", + "com.azure.ai.agents.persistent.MessagesAsyncClient.updateMessage": "Azure.AI.Agents.Messages.updateMessage", + "com.azure.ai.agents.persistent.MessagesAsyncClient.updateMessageWithResponse": "Azure.AI.Agents.Messages.updateMessage", + "com.azure.ai.agents.persistent.MessagesClient": "Azure.AI.Agents.Messages", + "com.azure.ai.agents.persistent.MessagesClient.createMessage": "Azure.AI.Agents.Messages.createMessage", + "com.azure.ai.agents.persistent.MessagesClient.createMessageWithResponse": "Azure.AI.Agents.Messages.createMessage", + "com.azure.ai.agents.persistent.MessagesClient.getMessage": "Azure.AI.Agents.Messages.getMessage", + "com.azure.ai.agents.persistent.MessagesClient.getMessageWithResponse": "Azure.AI.Agents.Messages.getMessage", + "com.azure.ai.agents.persistent.MessagesClient.listMessages": "Azure.AI.Agents.Messages.listMessages", + "com.azure.ai.agents.persistent.MessagesClient.updateMessage": "Azure.AI.Agents.Messages.updateMessage", + "com.azure.ai.agents.persistent.MessagesClient.updateMessageWithResponse": "Azure.AI.Agents.Messages.updateMessage", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient": "Azure.AI.Agents", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.createAgent": "Azure.AI.Agents.createAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.createAgentWithResponse": "Azure.AI.Agents.createAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.createThreadAndRun": "Azure.AI.Agents.createThreadAndRun", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.createThreadAndRunWithResponse": "Azure.AI.Agents.createThreadAndRun", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.deleteAgent": "Azure.AI.Agents.deleteAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.deleteAgentWithResponse": "Azure.AI.Agents.deleteAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.getAgent": "Azure.AI.Agents.getAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.getAgentWithResponse": "Azure.AI.Agents.getAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.listAgents": "Azure.AI.Agents.listAgents", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.updateAgent": "Azure.AI.Agents.updateAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationAsyncClient.updateAgentWithResponse": "Azure.AI.Agents.updateAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient": "Azure.AI.Agents", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.createAgent": "Azure.AI.Agents.createAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.createAgentWithResponse": "Azure.AI.Agents.createAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.createThreadAndRun": "Azure.AI.Agents.createThreadAndRun", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.createThreadAndRunWithResponse": "Azure.AI.Agents.createThreadAndRun", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.deleteAgent": "Azure.AI.Agents.deleteAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.deleteAgentWithResponse": "Azure.AI.Agents.deleteAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.getAgent": "Azure.AI.Agents.getAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.getAgentWithResponse": "Azure.AI.Agents.getAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.listAgents": "Azure.AI.Agents.listAgents", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.updateAgent": "Azure.AI.Agents.updateAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient.updateAgentWithResponse": "Azure.AI.Agents.updateAgent", + "com.azure.ai.agents.persistent.PersistentAgentsAdministrationClientBuilder": "Azure.AI.Agents", + "com.azure.ai.agents.persistent.RunStepsAsyncClient": "Azure.AI.Agents.RunSteps", + "com.azure.ai.agents.persistent.RunStepsAsyncClient.getRunStep": "Azure.AI.Agents.RunSteps.getRunStep", + "com.azure.ai.agents.persistent.RunStepsAsyncClient.getRunStepWithResponse": "Azure.AI.Agents.RunSteps.getRunStep", + "com.azure.ai.agents.persistent.RunStepsAsyncClient.listRunSteps": "Azure.AI.Agents.RunSteps.listRunSteps", + "com.azure.ai.agents.persistent.RunStepsClient": "Azure.AI.Agents.RunSteps", + "com.azure.ai.agents.persistent.RunStepsClient.getRunStep": "Azure.AI.Agents.RunSteps.getRunStep", + "com.azure.ai.agents.persistent.RunStepsClient.getRunStepWithResponse": "Azure.AI.Agents.RunSteps.getRunStep", + "com.azure.ai.agents.persistent.RunStepsClient.listRunSteps": "Azure.AI.Agents.RunSteps.listRunSteps", + "com.azure.ai.agents.persistent.RunsAsyncClient": "Azure.AI.Agents.Runs", + "com.azure.ai.agents.persistent.RunsAsyncClient.cancelRun": "Azure.AI.Agents.Runs.cancelRun", + "com.azure.ai.agents.persistent.RunsAsyncClient.cancelRunWithResponse": "Azure.AI.Agents.Runs.cancelRun", + "com.azure.ai.agents.persistent.RunsAsyncClient.createRun": "Azure.AI.Agents.Runs.createRun", + "com.azure.ai.agents.persistent.RunsAsyncClient.createRunWithResponse": "Azure.AI.Agents.Runs.createRun", + "com.azure.ai.agents.persistent.RunsAsyncClient.getRun": "Azure.AI.Agents.Runs.getRun", + "com.azure.ai.agents.persistent.RunsAsyncClient.getRunWithResponse": "Azure.AI.Agents.Runs.getRun", + "com.azure.ai.agents.persistent.RunsAsyncClient.listRuns": "Azure.AI.Agents.Runs.listRuns", + "com.azure.ai.agents.persistent.RunsAsyncClient.submitToolOutputsToRun": "Azure.AI.Agents.Runs.submitToolOutputsToRun", + "com.azure.ai.agents.persistent.RunsAsyncClient.submitToolOutputsToRunWithResponse": "Azure.AI.Agents.Runs.submitToolOutputsToRun", + "com.azure.ai.agents.persistent.RunsAsyncClient.updateRun": "Azure.AI.Agents.Runs.updateRun", + "com.azure.ai.agents.persistent.RunsAsyncClient.updateRunWithResponse": "Azure.AI.Agents.Runs.updateRun", + "com.azure.ai.agents.persistent.RunsClient": "Azure.AI.Agents.Runs", + "com.azure.ai.agents.persistent.RunsClient.cancelRun": "Azure.AI.Agents.Runs.cancelRun", + "com.azure.ai.agents.persistent.RunsClient.cancelRunWithResponse": "Azure.AI.Agents.Runs.cancelRun", + "com.azure.ai.agents.persistent.RunsClient.createRun": "Azure.AI.Agents.Runs.createRun", + "com.azure.ai.agents.persistent.RunsClient.createRunWithResponse": "Azure.AI.Agents.Runs.createRun", + "com.azure.ai.agents.persistent.RunsClient.getRun": "Azure.AI.Agents.Runs.getRun", + "com.azure.ai.agents.persistent.RunsClient.getRunWithResponse": "Azure.AI.Agents.Runs.getRun", + "com.azure.ai.agents.persistent.RunsClient.listRuns": "Azure.AI.Agents.Runs.listRuns", + "com.azure.ai.agents.persistent.RunsClient.submitToolOutputsToRun": "Azure.AI.Agents.Runs.submitToolOutputsToRun", + "com.azure.ai.agents.persistent.RunsClient.submitToolOutputsToRunWithResponse": "Azure.AI.Agents.Runs.submitToolOutputsToRun", + "com.azure.ai.agents.persistent.RunsClient.updateRun": "Azure.AI.Agents.Runs.updateRun", + "com.azure.ai.agents.persistent.RunsClient.updateRunWithResponse": "Azure.AI.Agents.Runs.updateRun", + "com.azure.ai.agents.persistent.ThreadsAsyncClient": "Azure.AI.Agents.Threads", + "com.azure.ai.agents.persistent.ThreadsAsyncClient.createThread": "Azure.AI.Agents.Threads.createThread", + "com.azure.ai.agents.persistent.ThreadsAsyncClient.createThreadWithResponse": "Azure.AI.Agents.Threads.createThread", + "com.azure.ai.agents.persistent.ThreadsAsyncClient.deleteThread": "Azure.AI.Agents.Threads.deleteThread", + "com.azure.ai.agents.persistent.ThreadsAsyncClient.deleteThreadWithResponse": "Azure.AI.Agents.Threads.deleteThread", + "com.azure.ai.agents.persistent.ThreadsAsyncClient.getThread": "Azure.AI.Agents.Threads.getThread", + "com.azure.ai.agents.persistent.ThreadsAsyncClient.getThreadWithResponse": "Azure.AI.Agents.Threads.getThread", + "com.azure.ai.agents.persistent.ThreadsAsyncClient.listThreads": "Azure.AI.Agents.Threads.listThreads", + "com.azure.ai.agents.persistent.ThreadsAsyncClient.updateThread": "Azure.AI.Agents.Threads.updateThread", + "com.azure.ai.agents.persistent.ThreadsAsyncClient.updateThreadWithResponse": "Azure.AI.Agents.Threads.updateThread", + "com.azure.ai.agents.persistent.ThreadsClient": "Azure.AI.Agents.Threads", + "com.azure.ai.agents.persistent.ThreadsClient.createThread": "Azure.AI.Agents.Threads.createThread", + "com.azure.ai.agents.persistent.ThreadsClient.createThreadWithResponse": "Azure.AI.Agents.Threads.createThread", + "com.azure.ai.agents.persistent.ThreadsClient.deleteThread": "Azure.AI.Agents.Threads.deleteThread", + "com.azure.ai.agents.persistent.ThreadsClient.deleteThreadWithResponse": "Azure.AI.Agents.Threads.deleteThread", + "com.azure.ai.agents.persistent.ThreadsClient.getThread": "Azure.AI.Agents.Threads.getThread", + "com.azure.ai.agents.persistent.ThreadsClient.getThreadWithResponse": "Azure.AI.Agents.Threads.getThread", + "com.azure.ai.agents.persistent.ThreadsClient.listThreads": "Azure.AI.Agents.Threads.listThreads", + "com.azure.ai.agents.persistent.ThreadsClient.updateThread": "Azure.AI.Agents.Threads.updateThread", + "com.azure.ai.agents.persistent.ThreadsClient.updateThreadWithResponse": "Azure.AI.Agents.Threads.updateThread", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesAsyncClient": "Azure.AI.Agents.VectorStoreFileBatches", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesAsyncClient.cancelVectorStoreFileBatch": "Azure.AI.Agents.VectorStoreFileBatches.cancelVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesAsyncClient.cancelVectorStoreFileBatchWithResponse": "Azure.AI.Agents.VectorStoreFileBatches.cancelVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesAsyncClient.createVectorStoreFileBatch": "Azure.AI.Agents.VectorStoreFileBatches.createVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesAsyncClient.createVectorStoreFileBatchWithResponse": "Azure.AI.Agents.VectorStoreFileBatches.createVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesAsyncClient.getVectorStoreFileBatch": "Azure.AI.Agents.VectorStoreFileBatches.getVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesAsyncClient.getVectorStoreFileBatchWithResponse": "Azure.AI.Agents.VectorStoreFileBatches.getVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesAsyncClient.listVectorStoreFileBatchFiles": "Azure.AI.Agents.VectorStoreFileBatches.listVectorStoreFileBatchFiles", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesClient": "Azure.AI.Agents.VectorStoreFileBatches", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesClient.cancelVectorStoreFileBatch": "Azure.AI.Agents.VectorStoreFileBatches.cancelVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesClient.cancelVectorStoreFileBatchWithResponse": "Azure.AI.Agents.VectorStoreFileBatches.cancelVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesClient.createVectorStoreFileBatch": "Azure.AI.Agents.VectorStoreFileBatches.createVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesClient.createVectorStoreFileBatchWithResponse": "Azure.AI.Agents.VectorStoreFileBatches.createVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesClient.getVectorStoreFileBatch": "Azure.AI.Agents.VectorStoreFileBatches.getVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesClient.getVectorStoreFileBatchWithResponse": "Azure.AI.Agents.VectorStoreFileBatches.getVectorStoreFileBatch", + "com.azure.ai.agents.persistent.VectorStoreFileBatchesClient.listVectorStoreFileBatchFiles": "Azure.AI.Agents.VectorStoreFileBatches.listVectorStoreFileBatchFiles", + "com.azure.ai.agents.persistent.VectorStoreFilesAsyncClient": "Azure.AI.Agents.VectorStoreFiles", + "com.azure.ai.agents.persistent.VectorStoreFilesAsyncClient.createVectorStoreFile": "Azure.AI.Agents.VectorStoreFiles.createVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesAsyncClient.createVectorStoreFileWithResponse": "Azure.AI.Agents.VectorStoreFiles.createVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesAsyncClient.deleteVectorStoreFile": "Azure.AI.Agents.VectorStoreFiles.deleteVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesAsyncClient.deleteVectorStoreFileWithResponse": "Azure.AI.Agents.VectorStoreFiles.deleteVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesAsyncClient.getVectorStoreFile": "Azure.AI.Agents.VectorStoreFiles.getVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesAsyncClient.getVectorStoreFileWithResponse": "Azure.AI.Agents.VectorStoreFiles.getVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesAsyncClient.listVectorStoreFiles": "Azure.AI.Agents.VectorStoreFiles.listVectorStoreFiles", + "com.azure.ai.agents.persistent.VectorStoreFilesClient": "Azure.AI.Agents.VectorStoreFiles", + "com.azure.ai.agents.persistent.VectorStoreFilesClient.createVectorStoreFile": "Azure.AI.Agents.VectorStoreFiles.createVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesClient.createVectorStoreFileWithResponse": "Azure.AI.Agents.VectorStoreFiles.createVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesClient.deleteVectorStoreFile": "Azure.AI.Agents.VectorStoreFiles.deleteVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesClient.deleteVectorStoreFileWithResponse": "Azure.AI.Agents.VectorStoreFiles.deleteVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesClient.getVectorStoreFile": "Azure.AI.Agents.VectorStoreFiles.getVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesClient.getVectorStoreFileWithResponse": "Azure.AI.Agents.VectorStoreFiles.getVectorStoreFile", + "com.azure.ai.agents.persistent.VectorStoreFilesClient.listVectorStoreFiles": "Azure.AI.Agents.VectorStoreFiles.listVectorStoreFiles", + "com.azure.ai.agents.persistent.VectorStoresAsyncClient": "Azure.AI.Agents.VectorStores", + "com.azure.ai.agents.persistent.VectorStoresAsyncClient.createVectorStore": "Azure.AI.Agents.VectorStores.createVectorStore", + "com.azure.ai.agents.persistent.VectorStoresAsyncClient.createVectorStoreWithResponse": "Azure.AI.Agents.VectorStores.createVectorStore", + "com.azure.ai.agents.persistent.VectorStoresAsyncClient.deleteVectorStore": "Azure.AI.Agents.VectorStores.deleteVectorStore", + "com.azure.ai.agents.persistent.VectorStoresAsyncClient.deleteVectorStoreWithResponse": "Azure.AI.Agents.VectorStores.deleteVectorStore", + "com.azure.ai.agents.persistent.VectorStoresAsyncClient.getVectorStore": "Azure.AI.Agents.VectorStores.getVectorStore", + "com.azure.ai.agents.persistent.VectorStoresAsyncClient.getVectorStoreWithResponse": "Azure.AI.Agents.VectorStores.getVectorStore", + "com.azure.ai.agents.persistent.VectorStoresAsyncClient.listVectorStores": "Azure.AI.Agents.VectorStores.listVectorStores", + "com.azure.ai.agents.persistent.VectorStoresAsyncClient.modifyVectorStore": "Azure.AI.Agents.VectorStores.modifyVectorStore", + "com.azure.ai.agents.persistent.VectorStoresAsyncClient.modifyVectorStoreWithResponse": "Azure.AI.Agents.VectorStores.modifyVectorStore", + "com.azure.ai.agents.persistent.VectorStoresClient": "Azure.AI.Agents.VectorStores", + "com.azure.ai.agents.persistent.VectorStoresClient.createVectorStore": "Azure.AI.Agents.VectorStores.createVectorStore", + "com.azure.ai.agents.persistent.VectorStoresClient.createVectorStoreWithResponse": "Azure.AI.Agents.VectorStores.createVectorStore", + "com.azure.ai.agents.persistent.VectorStoresClient.deleteVectorStore": "Azure.AI.Agents.VectorStores.deleteVectorStore", + "com.azure.ai.agents.persistent.VectorStoresClient.deleteVectorStoreWithResponse": "Azure.AI.Agents.VectorStores.deleteVectorStore", + "com.azure.ai.agents.persistent.VectorStoresClient.getVectorStore": "Azure.AI.Agents.VectorStores.getVectorStore", + "com.azure.ai.agents.persistent.VectorStoresClient.getVectorStoreWithResponse": "Azure.AI.Agents.VectorStores.getVectorStore", + "com.azure.ai.agents.persistent.VectorStoresClient.listVectorStores": "Azure.AI.Agents.VectorStores.listVectorStores", + "com.azure.ai.agents.persistent.VectorStoresClient.modifyVectorStore": "Azure.AI.Agents.VectorStores.modifyVectorStore", + "com.azure.ai.agents.persistent.VectorStoresClient.modifyVectorStoreWithResponse": "Azure.AI.Agents.VectorStores.modifyVectorStore", + "com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest": "Azure.AI.Agents.createAgent.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.CreateMessageRequest": "Azure.AI.Agents.createMessage.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.CreateRunRequest": "Azure.AI.Agents.createRun.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.CreateThreadAndRunRequest": "Azure.AI.Agents.createThreadAndRun.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.CreateThreadRequest": "Azure.AI.Agents.createThread.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.CreateVectorStoreFileBatchRequest": "Azure.AI.Agents.createVectorStoreFileBatch.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.CreateVectorStoreFileRequest": "Azure.AI.Agents.createVectorStoreFile.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.CreateVectorStoreRequest": "Azure.AI.Agents.createVectorStore.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.FileDetails": "TypeSpec.Http.File", + "com.azure.ai.agents.persistent.implementation.models.ModifyVectorStoreRequest": "Azure.AI.Agents.modifyVectorStore.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.SubmitToolOutputsToRunRequest": "Azure.AI.Agents.submitToolOutputsToRun.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.UpdateAgentRequest": "Azure.AI.Agents.updateAgent.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.UpdateMessageRequest": "Azure.AI.Agents.updateMessage.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.UpdateRunRequest": "Azure.AI.Agents.updateRun.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.UpdateThreadRequest": "Azure.AI.Agents.updateThread.Request.anonymous", + "com.azure.ai.agents.persistent.implementation.models.UploadFileRequest": "Azure.AI.Agents.uploadFile.Request.anonymous", + "com.azure.ai.agents.persistent.models.AISearchIndexResource": "Azure.AI.Agents.AISearchIndexResource", + "com.azure.ai.agents.persistent.models.AgentDeletionStatus": "Azure.AI.Agents.AgentDeletionStatus", + "com.azure.ai.agents.persistent.models.AzureAISearchQueryType": "Azure.AI.Agents.AzureAISearchQueryType", + "com.azure.ai.agents.persistent.models.AzureAISearchResource": "Azure.AI.Agents.AzureAISearchResource", + "com.azure.ai.agents.persistent.models.AzureAISearchToolDefinition": "Azure.AI.Agents.AzureAISearchToolDefinition", + "com.azure.ai.agents.persistent.models.AzureFunctionBinding": "Azure.AI.Agents.AzureFunctionBinding", + "com.azure.ai.agents.persistent.models.AzureFunctionDefinition": "Azure.AI.Agents.AzureFunctionDefinition", + "com.azure.ai.agents.persistent.models.AzureFunctionStorageQueue": "Azure.AI.Agents.AzureFunctionStorageQueue", + "com.azure.ai.agents.persistent.models.AzureFunctionToolDefinition": "Azure.AI.Agents.AzureFunctionToolDefinition", + "com.azure.ai.agents.persistent.models.BingCustomSearchConfiguration": "Azure.AI.Agents.BingCustomSearchConfiguration", + "com.azure.ai.agents.persistent.models.BingCustomSearchConfigurationList": "Azure.AI.Agents.BingCustomSearchConfigurationList", + "com.azure.ai.agents.persistent.models.BingCustomSearchToolDefinition": "Azure.AI.Agents.BingCustomSearchToolDefinition", + "com.azure.ai.agents.persistent.models.BingGroundingSearchConfiguration": "Azure.AI.Agents.BingGroundingSearchConfiguration", + "com.azure.ai.agents.persistent.models.BingGroundingSearchConfigurationList": "Azure.AI.Agents.BingGroundingSearchConfigurationList", + "com.azure.ai.agents.persistent.models.BingGroundingToolDefinition": "Azure.AI.Agents.BingGroundingToolDefinition", + "com.azure.ai.agents.persistent.models.CodeInterpreterToolDefinition": "Azure.AI.Agents.CodeInterpreterToolDefinition", + "com.azure.ai.agents.persistent.models.CodeInterpreterToolResource": "Azure.AI.Agents.CodeInterpreterToolResource", + "com.azure.ai.agents.persistent.models.ConnectedAgentDetails": "Azure.AI.Agents.ConnectedAgentDetails", + "com.azure.ai.agents.persistent.models.ConnectedAgentToolDefinition": "Azure.AI.Agents.ConnectedAgentToolDefinition", + "com.azure.ai.agents.persistent.models.CreateAgentOptions": null, + "com.azure.ai.agents.persistent.models.CreateRunOptions": null, + "com.azure.ai.agents.persistent.models.CreateThreadAndRunOptions": null, + "com.azure.ai.agents.persistent.models.DoneEvent": "Azure.AI.Agents.DoneEvent", + "com.azure.ai.agents.persistent.models.ErrorEvent": "Azure.AI.Agents.ErrorEvent", + "com.azure.ai.agents.persistent.models.FileDeletionStatus": "Azure.AI.Agents.FileDeletionStatus", + "com.azure.ai.agents.persistent.models.FileInfo": "Azure.AI.Agents.FileInfo", + "com.azure.ai.agents.persistent.models.FileListResponse": "Azure.AI.Agents.FileListResponse", + "com.azure.ai.agents.persistent.models.FilePurpose": "Azure.AI.Agents.FilePurpose", + "com.azure.ai.agents.persistent.models.FileSearchRankingOptions": "Azure.AI.Agents.FileSearchRankingOptions", + "com.azure.ai.agents.persistent.models.FileSearchToolCallContent": "Azure.AI.Agents.FileSearchToolCallContent", + "com.azure.ai.agents.persistent.models.FileSearchToolDefinition": "Azure.AI.Agents.FileSearchToolDefinition", + "com.azure.ai.agents.persistent.models.FileSearchToolDefinitionDetails": "Azure.AI.Agents.FileSearchToolDefinitionDetails", + "com.azure.ai.agents.persistent.models.FileSearchToolResource": "Azure.AI.Agents.FileSearchToolResource", + "com.azure.ai.agents.persistent.models.FileState": "Azure.AI.Agents.FileState", + "com.azure.ai.agents.persistent.models.FunctionDefinition": "Azure.AI.Agents.FunctionDefinition", + "com.azure.ai.agents.persistent.models.FunctionName": "Azure.AI.Agents.FunctionName", + "com.azure.ai.agents.persistent.models.FunctionToolDefinition": "Azure.AI.Agents.FunctionToolDefinition", + "com.azure.ai.agents.persistent.models.ImageDetailLevel": "Azure.AI.Agents.ImageDetailLevel", + "com.azure.ai.agents.persistent.models.IncompleteDetailsReason": "Azure.AI.Agents.IncompleteDetailsReason", + "com.azure.ai.agents.persistent.models.IncompleteRunDetails": "Azure.AI.Agents.IncompleteRunDetails", + "com.azure.ai.agents.persistent.models.ListSortOrder": "Azure.AI.Agents.ListSortOrder", + "com.azure.ai.agents.persistent.models.MessageAttachment": "Azure.AI.Agents.MessageAttachment", + "com.azure.ai.agents.persistent.models.MessageBlockType": "Azure.AI.Agents.MessageBlockType", + "com.azure.ai.agents.persistent.models.MessageContent": "Azure.AI.Agents.MessageContent", + "com.azure.ai.agents.persistent.models.MessageDelta": "Azure.AI.Agents.MessageDelta", + "com.azure.ai.agents.persistent.models.MessageDeltaChunk": "Azure.AI.Agents.MessageDeltaChunk", + "com.azure.ai.agents.persistent.models.MessageDeltaContent": "Azure.AI.Agents.MessageDeltaContent", + "com.azure.ai.agents.persistent.models.MessageDeltaImageFileContent": "Azure.AI.Agents.MessageDeltaImageFileContent", + "com.azure.ai.agents.persistent.models.MessageDeltaImageFileContentObject": "Azure.AI.Agents.MessageDeltaImageFileContentObject", + "com.azure.ai.agents.persistent.models.MessageDeltaTextAnnotation": "Azure.AI.Agents.MessageDeltaTextAnnotation", + "com.azure.ai.agents.persistent.models.MessageDeltaTextContent": "Azure.AI.Agents.MessageDeltaTextContent", + "com.azure.ai.agents.persistent.models.MessageDeltaTextContentObject": "Azure.AI.Agents.MessageDeltaTextContentObject", + "com.azure.ai.agents.persistent.models.MessageDeltaTextFileCitationAnnotation": "Azure.AI.Agents.MessageDeltaTextFileCitationAnnotation", + "com.azure.ai.agents.persistent.models.MessageDeltaTextFileCitationAnnotationObject": "Azure.AI.Agents.MessageDeltaTextFileCitationAnnotationObject", + "com.azure.ai.agents.persistent.models.MessageDeltaTextFilePathAnnotation": "Azure.AI.Agents.MessageDeltaTextFilePathAnnotation", + "com.azure.ai.agents.persistent.models.MessageDeltaTextFilePathAnnotationObject": "Azure.AI.Agents.MessageDeltaTextFilePathAnnotationObject", + "com.azure.ai.agents.persistent.models.MessageDeltaTextUrlCitationAnnotation": "Azure.AI.Agents.MessageDeltaTextUrlCitationAnnotation", + "com.azure.ai.agents.persistent.models.MessageDeltaTextUrlCitationDetails": "Azure.AI.Agents.MessageDeltaTextUrlCitationDetails", + "com.azure.ai.agents.persistent.models.MessageImageFileContent": "Azure.AI.Agents.MessageImageFileContent", + "com.azure.ai.agents.persistent.models.MessageImageFileDetails": "Azure.AI.Agents.MessageImageFileDetails", + "com.azure.ai.agents.persistent.models.MessageImageFileParam": "Azure.AI.Agents.MessageImageFileParam", + "com.azure.ai.agents.persistent.models.MessageImageUrlParam": "Azure.AI.Agents.MessageImageUrlParam", + "com.azure.ai.agents.persistent.models.MessageIncompleteDetails": "Azure.AI.Agents.MessageIncompleteDetails", + "com.azure.ai.agents.persistent.models.MessageIncompleteDetailsReason": "Azure.AI.Agents.MessageIncompleteDetailsReason", + "com.azure.ai.agents.persistent.models.MessageInputContentBlock": "Azure.AI.Agents.MessageInputContentBlock", + "com.azure.ai.agents.persistent.models.MessageInputImageFileBlock": "Azure.AI.Agents.MessageInputImageFileBlock", + "com.azure.ai.agents.persistent.models.MessageInputImageUrlBlock": "Azure.AI.Agents.MessageInputImageUrlBlock", + "com.azure.ai.agents.persistent.models.MessageInputTextBlock": "Azure.AI.Agents.MessageInputTextBlock", + "com.azure.ai.agents.persistent.models.MessageRole": "Azure.AI.Agents.MessageRole", + "com.azure.ai.agents.persistent.models.MessageStatus": "Azure.AI.Agents.MessageStatus", + "com.azure.ai.agents.persistent.models.MessageStreamEvent": "Azure.AI.Agents.MessageStreamEvent", + "com.azure.ai.agents.persistent.models.MessageTextAnnotation": "Azure.AI.Agents.MessageTextAnnotation", + "com.azure.ai.agents.persistent.models.MessageTextContent": "Azure.AI.Agents.MessageTextContent", + "com.azure.ai.agents.persistent.models.MessageTextDetails": "Azure.AI.Agents.MessageTextDetails", + "com.azure.ai.agents.persistent.models.MessageTextFileCitationAnnotation": "Azure.AI.Agents.MessageTextFileCitationAnnotation", + "com.azure.ai.agents.persistent.models.MessageTextFileCitationDetails": "Azure.AI.Agents.MessageTextFileCitationDetails", + "com.azure.ai.agents.persistent.models.MessageTextFilePathAnnotation": "Azure.AI.Agents.MessageTextFilePathAnnotation", + "com.azure.ai.agents.persistent.models.MessageTextFilePathDetails": "Azure.AI.Agents.MessageTextFilePathDetails", + "com.azure.ai.agents.persistent.models.MessageTextUrlCitationAnnotation": "Azure.AI.Agents.MessageTextUrlCitationAnnotation", + "com.azure.ai.agents.persistent.models.MessageTextUrlCitationDetails": "Azure.AI.Agents.MessageTextUrlCitationDetails", + "com.azure.ai.agents.persistent.models.MicrosoftFabricToolDefinition": "Azure.AI.Agents.MicrosoftFabricToolDefinition", + "com.azure.ai.agents.persistent.models.OpenApiAnonymousAuthDetails": "Azure.AI.Agents.OpenApiAnonymousAuthDetails", + "com.azure.ai.agents.persistent.models.OpenApiAuthDetails": "Azure.AI.Agents.OpenApiAuthDetails", + "com.azure.ai.agents.persistent.models.OpenApiAuthType": "Azure.AI.Agents.OpenApiAuthType", + "com.azure.ai.agents.persistent.models.OpenApiConnectionAuthDetails": "Azure.AI.Agents.OpenApiConnectionAuthDetails", + "com.azure.ai.agents.persistent.models.OpenApiConnectionSecurityScheme": "Azure.AI.Agents.OpenApiConnectionSecurityScheme", + "com.azure.ai.agents.persistent.models.OpenApiFunctionDefinition": "Azure.AI.Agents.OpenApiFunctionDefinition", + "com.azure.ai.agents.persistent.models.OpenApiManagedAuthDetails": "Azure.AI.Agents.OpenApiManagedAuthDetails", + "com.azure.ai.agents.persistent.models.OpenApiManagedSecurityScheme": "Azure.AI.Agents.OpenApiManagedSecurityScheme", + "com.azure.ai.agents.persistent.models.OpenApiToolDefinition": "Azure.AI.Agents.OpenApiToolDefinition", + "com.azure.ai.agents.persistent.models.PersistentAgent": "Azure.AI.Agents.Agent", + "com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent": "Azure.AI.Agents.AgentStreamEvent", + "com.azure.ai.agents.persistent.models.PersistentAgentThread": "Azure.AI.Agents.AgentThread", + "com.azure.ai.agents.persistent.models.PersistentAgentThreadCreationOptions": "Azure.AI.Agents.AgentThreadCreationOptions", + "com.azure.ai.agents.persistent.models.PersistentAgentsNamedToolChoice": "Azure.AI.Agents.AgentsNamedToolChoice", + "com.azure.ai.agents.persistent.models.PersistentAgentsNamedToolChoiceType": "Azure.AI.Agents.AgentsNamedToolChoiceType", + "com.azure.ai.agents.persistent.models.PersistentAgentsResponseFormat": "Azure.AI.Agents.AgentsResponseFormat", + "com.azure.ai.agents.persistent.models.PersistentAgentsResponseFormatMode": "Azure.AI.Agents.AgentsResponseFormatMode", + "com.azure.ai.agents.persistent.models.PersistentAgentsToolChoiceOptionMode": "Azure.AI.Agents.AgentsToolChoiceOptionMode", + "com.azure.ai.agents.persistent.models.RequiredAction": "Azure.AI.Agents.RequiredAction", + "com.azure.ai.agents.persistent.models.RequiredFunctionToolCall": "Azure.AI.Agents.RequiredFunctionToolCall", + "com.azure.ai.agents.persistent.models.RequiredFunctionToolCallDetails": "Azure.AI.Agents.RequiredFunctionToolCallDetails", + "com.azure.ai.agents.persistent.models.RequiredToolCall": "Azure.AI.Agents.RequiredToolCall", + "com.azure.ai.agents.persistent.models.ResponseFormat": "Azure.AI.Agents.ResponseFormat", + "com.azure.ai.agents.persistent.models.ResponseFormatJsonSchema": "Azure.AI.Agents.ResponseFormatJsonSchema", + "com.azure.ai.agents.persistent.models.ResponseFormatJsonSchemaType": "Azure.AI.Agents.ResponseFormatJsonSchemaType", + "com.azure.ai.agents.persistent.models.RunAdditionalFieldList": "Azure.AI.Agents.RunAdditionalFieldList", + "com.azure.ai.agents.persistent.models.RunCompletionUsage": "Azure.AI.Agents.RunCompletionUsage", + "com.azure.ai.agents.persistent.models.RunError": "Azure.AI.Agents.RunError", + "com.azure.ai.agents.persistent.models.RunStatus": "Azure.AI.Agents.RunStatus", + "com.azure.ai.agents.persistent.models.RunStep": "Azure.AI.Agents.RunStep", + "com.azure.ai.agents.persistent.models.RunStepAzureAISearchToolCall": "Azure.AI.Agents.RunStepAzureAISearchToolCall", + "com.azure.ai.agents.persistent.models.RunStepBingCustomSearchToolCall": "Azure.AI.Agents.RunStepBingCustomSearchToolCall", + "com.azure.ai.agents.persistent.models.RunStepBingGroundingToolCall": "Azure.AI.Agents.RunStepBingGroundingToolCall", + "com.azure.ai.agents.persistent.models.RunStepCodeInterpreterImageOutput": "Azure.AI.Agents.RunStepCodeInterpreterImageOutput", + "com.azure.ai.agents.persistent.models.RunStepCodeInterpreterImageReference": "Azure.AI.Agents.RunStepCodeInterpreterImageReference", + "com.azure.ai.agents.persistent.models.RunStepCodeInterpreterLogOutput": "Azure.AI.Agents.RunStepCodeInterpreterLogOutput", + "com.azure.ai.agents.persistent.models.RunStepCodeInterpreterToolCall": "Azure.AI.Agents.RunStepCodeInterpreterToolCall", + "com.azure.ai.agents.persistent.models.RunStepCodeInterpreterToolCallDetails": "Azure.AI.Agents.RunStepCodeInterpreterToolCallDetails", + "com.azure.ai.agents.persistent.models.RunStepCodeInterpreterToolCallOutput": "Azure.AI.Agents.RunStepCodeInterpreterToolCallOutput", + "com.azure.ai.agents.persistent.models.RunStepCompletionUsage": "Azure.AI.Agents.RunStepCompletionUsage", + "com.azure.ai.agents.persistent.models.RunStepDelta": "Azure.AI.Agents.RunStepDelta", + "com.azure.ai.agents.persistent.models.RunStepDeltaChunk": "Azure.AI.Agents.RunStepDeltaChunk", + "com.azure.ai.agents.persistent.models.RunStepDeltaCodeInterpreterDetailItemObject": "Azure.AI.Agents.RunStepDeltaCodeInterpreterDetailItemObject", + "com.azure.ai.agents.persistent.models.RunStepDeltaCodeInterpreterImageOutput": "Azure.AI.Agents.RunStepDeltaCodeInterpreterImageOutput", + "com.azure.ai.agents.persistent.models.RunStepDeltaCodeInterpreterImageOutputObject": "Azure.AI.Agents.RunStepDeltaCodeInterpreterImageOutputObject", + "com.azure.ai.agents.persistent.models.RunStepDeltaCodeInterpreterLogOutput": "Azure.AI.Agents.RunStepDeltaCodeInterpreterLogOutput", + "com.azure.ai.agents.persistent.models.RunStepDeltaCodeInterpreterOutput": "Azure.AI.Agents.RunStepDeltaCodeInterpreterOutput", + "com.azure.ai.agents.persistent.models.RunStepDeltaCodeInterpreterToolCall": "Azure.AI.Agents.RunStepDeltaCodeInterpreterToolCall", + "com.azure.ai.agents.persistent.models.RunStepDeltaDetail": "Azure.AI.Agents.RunStepDeltaDetail", + "com.azure.ai.agents.persistent.models.RunStepDeltaFileSearchToolCall": "Azure.AI.Agents.RunStepDeltaFileSearchToolCall", + "com.azure.ai.agents.persistent.models.RunStepDeltaFunction": "Azure.AI.Agents.RunStepDeltaFunction", + "com.azure.ai.agents.persistent.models.RunStepDeltaFunctionToolCall": "Azure.AI.Agents.RunStepDeltaFunctionToolCall", + "com.azure.ai.agents.persistent.models.RunStepDeltaMessageCreation": "Azure.AI.Agents.RunStepDeltaMessageCreation", + "com.azure.ai.agents.persistent.models.RunStepDeltaMessageCreationObject": "Azure.AI.Agents.RunStepDeltaMessageCreationObject", + "com.azure.ai.agents.persistent.models.RunStepDeltaToolCall": "Azure.AI.Agents.RunStepDeltaToolCall", + "com.azure.ai.agents.persistent.models.RunStepDeltaToolCallObject": "Azure.AI.Agents.RunStepDeltaToolCallObject", + "com.azure.ai.agents.persistent.models.RunStepDetails": "Azure.AI.Agents.RunStepDetails", + "com.azure.ai.agents.persistent.models.RunStepError": "Azure.AI.Agents.RunStepError", + "com.azure.ai.agents.persistent.models.RunStepErrorCode": "Azure.AI.Agents.RunStepErrorCode", + "com.azure.ai.agents.persistent.models.RunStepFileSearchToolCall": "Azure.AI.Agents.RunStepFileSearchToolCall", + "com.azure.ai.agents.persistent.models.RunStepFileSearchToolCallResult": "Azure.AI.Agents.RunStepFileSearchToolCallResult", + "com.azure.ai.agents.persistent.models.RunStepFileSearchToolCallResults": "Azure.AI.Agents.RunStepFileSearchToolCallResults", + "com.azure.ai.agents.persistent.models.RunStepFunctionToolCall": "Azure.AI.Agents.RunStepFunctionToolCall", + "com.azure.ai.agents.persistent.models.RunStepFunctionToolCallDetails": "Azure.AI.Agents.RunStepFunctionToolCallDetails", + "com.azure.ai.agents.persistent.models.RunStepMessageCreationDetails": "Azure.AI.Agents.RunStepMessageCreationDetails", + "com.azure.ai.agents.persistent.models.RunStepMessageCreationReference": "Azure.AI.Agents.RunStepMessageCreationReference", + "com.azure.ai.agents.persistent.models.RunStepMicrosoftFabricToolCall": "Azure.AI.Agents.RunStepMicrosoftFabricToolCall", + "com.azure.ai.agents.persistent.models.RunStepOpenApiToolCall": "Azure.AI.Agents.RunStepOpenAPIToolCall", + "com.azure.ai.agents.persistent.models.RunStepSharepointToolCall": "Azure.AI.Agents.RunStepSharepointToolCall", + "com.azure.ai.agents.persistent.models.RunStepStatus": "Azure.AI.Agents.RunStepStatus", + "com.azure.ai.agents.persistent.models.RunStepStreamEvent": "Azure.AI.Agents.RunStepStreamEvent", + "com.azure.ai.agents.persistent.models.RunStepToolCall": "Azure.AI.Agents.RunStepToolCall", + "com.azure.ai.agents.persistent.models.RunStepToolCallDetails": "Azure.AI.Agents.RunStepToolCallDetails", + "com.azure.ai.agents.persistent.models.RunStepType": "Azure.AI.Agents.RunStepType", + "com.azure.ai.agents.persistent.models.RunStreamEvent": "Azure.AI.Agents.RunStreamEvent", + "com.azure.ai.agents.persistent.models.SharepointToolDefinition": "Azure.AI.Agents.SharepointToolDefinition", + "com.azure.ai.agents.persistent.models.SubmitToolOutputsAction": "Azure.AI.Agents.SubmitToolOutputsAction", + "com.azure.ai.agents.persistent.models.SubmitToolOutputsDetails": "Azure.AI.Agents.SubmitToolOutputsDetails", + "com.azure.ai.agents.persistent.models.ThreadDeletionStatus": "Azure.AI.Agents.ThreadDeletionStatus", + "com.azure.ai.agents.persistent.models.ThreadMessage": "Azure.AI.Agents.ThreadMessage", + "com.azure.ai.agents.persistent.models.ThreadMessageOptions": "Azure.AI.Agents.ThreadMessageOptions", + "com.azure.ai.agents.persistent.models.ThreadRun": "Azure.AI.Agents.ThreadRun", + "com.azure.ai.agents.persistent.models.ThreadStreamEvent": "Azure.AI.Agents.ThreadStreamEvent", + "com.azure.ai.agents.persistent.models.ToolConnection": "Azure.AI.Agents.ToolConnection", + "com.azure.ai.agents.persistent.models.ToolConnectionList": "Azure.AI.Agents.ToolConnectionList", + "com.azure.ai.agents.persistent.models.ToolDefinition": "Azure.AI.Agents.ToolDefinition", + "com.azure.ai.agents.persistent.models.ToolOutput": "Azure.AI.Agents.ToolOutput", + "com.azure.ai.agents.persistent.models.ToolResources": "Azure.AI.Agents.ToolResources", + "com.azure.ai.agents.persistent.models.TruncationObject": "Azure.AI.Agents.TruncationObject", + "com.azure.ai.agents.persistent.models.TruncationStrategy": "Azure.AI.Agents.TruncationStrategy", + "com.azure.ai.agents.persistent.models.UpdateAgentOptions": null, + "com.azure.ai.agents.persistent.models.UpdateCodeInterpreterToolResourceOptions": "Azure.AI.Agents.UpdateCodeInterpreterToolResourceOptions", + "com.azure.ai.agents.persistent.models.UpdateFileSearchToolResourceOptions": "Azure.AI.Agents.UpdateFileSearchToolResourceOptions", + "com.azure.ai.agents.persistent.models.UpdateToolResourcesOptions": "Azure.AI.Agents.UpdateToolResourcesOptions", + "com.azure.ai.agents.persistent.models.VectorStore": "Azure.AI.Agents.VectorStore", + "com.azure.ai.agents.persistent.models.VectorStoreAutoChunkingStrategyRequest": "Azure.AI.Agents.VectorStoreAutoChunkingStrategyRequest", + "com.azure.ai.agents.persistent.models.VectorStoreAutoChunkingStrategyResponse": "Azure.AI.Agents.VectorStoreAutoChunkingStrategyResponse", + "com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequest": "Azure.AI.Agents.VectorStoreChunkingStrategyRequest", + "com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyRequestType": "Azure.AI.Agents.VectorStoreChunkingStrategyRequestType", + "com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyResponse": "Azure.AI.Agents.VectorStoreChunkingStrategyResponse", + "com.azure.ai.agents.persistent.models.VectorStoreChunkingStrategyResponseType": "Azure.AI.Agents.VectorStoreChunkingStrategyResponseType", + "com.azure.ai.agents.persistent.models.VectorStoreConfiguration": "Azure.AI.Agents.VectorStoreConfiguration", + "com.azure.ai.agents.persistent.models.VectorStoreConfigurations": "Azure.AI.Agents.VectorStoreConfigurations", + "com.azure.ai.agents.persistent.models.VectorStoreDataSource": "Azure.AI.Agents.VectorStoreDataSource", + "com.azure.ai.agents.persistent.models.VectorStoreDataSourceAssetType": "Azure.AI.Agents.VectorStoreDataSourceAssetType", + "com.azure.ai.agents.persistent.models.VectorStoreDeletionStatus": "Azure.AI.Agents.VectorStoreDeletionStatus", + "com.azure.ai.agents.persistent.models.VectorStoreExpirationPolicy": "Azure.AI.Agents.VectorStoreExpirationPolicy", + "com.azure.ai.agents.persistent.models.VectorStoreExpirationPolicyAnchor": "Azure.AI.Agents.VectorStoreExpirationPolicyAnchor", + "com.azure.ai.agents.persistent.models.VectorStoreFile": "Azure.AI.Agents.VectorStoreFile", + "com.azure.ai.agents.persistent.models.VectorStoreFileBatch": "Azure.AI.Agents.VectorStoreFileBatch", + "com.azure.ai.agents.persistent.models.VectorStoreFileBatchStatus": "Azure.AI.Agents.VectorStoreFileBatchStatus", + "com.azure.ai.agents.persistent.models.VectorStoreFileCount": "Azure.AI.Agents.VectorStoreFileCount", + "com.azure.ai.agents.persistent.models.VectorStoreFileDeletionStatus": "Azure.AI.Agents.VectorStoreFileDeletionStatus", + "com.azure.ai.agents.persistent.models.VectorStoreFileError": "Azure.AI.Agents.VectorStoreFileError", + "com.azure.ai.agents.persistent.models.VectorStoreFileErrorCode": "Azure.AI.Agents.VectorStoreFileErrorCode", + "com.azure.ai.agents.persistent.models.VectorStoreFileStatus": "Azure.AI.Agents.VectorStoreFileStatus", + "com.azure.ai.agents.persistent.models.VectorStoreFileStatusFilter": "Azure.AI.Agents.VectorStoreFileStatusFilter", + "com.azure.ai.agents.persistent.models.VectorStoreStaticChunkingStrategyOptions": "Azure.AI.Agents.VectorStoreStaticChunkingStrategyOptions", + "com.azure.ai.agents.persistent.models.VectorStoreStaticChunkingStrategyRequest": "Azure.AI.Agents.VectorStoreStaticChunkingStrategyRequest", + "com.azure.ai.agents.persistent.models.VectorStoreStaticChunkingStrategyResponse": "Azure.AI.Agents.VectorStoreStaticChunkingStrategyResponse", + "com.azure.ai.agents.persistent.models.VectorStoreStatus": "Azure.AI.Agents.VectorStoreStatus" + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/resources/azure-ai-agents-persistent.properties b/sdk/ai/azure-ai-agents-persistent/src/main/resources/azure-ai-agents-persistent.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/main/resources/azure-ai-agents-persistent.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAdditionalMessageAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAdditionalMessageAsyncSample.java new file mode 100644 index 000000000000..dabe702a912e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAdditionalMessageAsyncSample.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CodeInterpreterToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.ThreadMessageOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public final class AgentAdditionalMessageAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + String agentName = "additional_message_example_async"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a personal electronics tutor. Write and run code to answer questions.") + .setTools(Arrays.asList(new CodeInterpreterToolDefinition())); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create full reactive chain to showcase reactive programming + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + // Create initial message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What is the impedance formula?" + ).flatMap(message -> { + System.out.println("Created initial message"); + + // Create run with additional messages + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalMessages(Arrays.asList( + new ThreadMessageOptions( + MessageRole.AGENT, BinaryData.fromString("E=mc^2") + ), + new ThreadMessageOptions( + MessageRole.USER, BinaryData.fromString("What is the impedance formula?") + ) + )); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }) + .doFinally(signalType -> { + // Always clean up resources regardless of success or failure + System.out.println("Cleaning up resources..."); + + // Clean up thread if created + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()) + .doOnSuccess(ignored -> System.out.println("Thread deleted: " + threadId.get())) + .doOnError(error -> System.err.println("Failed to delete thread: " + error.getMessage())) + .subscribe(); + } + + // Clean up agent if created + if (agentId.get() != null) { + agentsAsyncClient.deleteAgent(agentId.get()) + .doOnSuccess(ignored -> System.out.println("Agent deleted: " + agentId.get())) + .doOnError(error -> System.err.println("Failed to delete agent: " + error.getMessage())) + .subscribe(); + } + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAdditionalMessageSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAdditionalMessageSample.java new file mode 100644 index 000000000000..306689e626a1 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAdditionalMessageSample.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + + +import com.azure.ai.agents.persistent.models.CodeInterpreterToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadMessageOptions; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public final class AgentAdditionalMessageSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String agentName = "additional_message_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a personal electronics tutor. Write and run code to answer questions.") + .setTools(Arrays.asList(new CodeInterpreterToolDefinition())); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What is the impedance formula?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalMessages(Arrays.asList(new ThreadMessageOptions( + MessageRole.AGENT, BinaryData.fromString("E=mc^2") + ), new ThreadMessageOptions( + MessageRole.USER, BinaryData.fromString("What is the impedance formula?") + ))); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } + +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureAISearchAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureAISearchAsyncSample.java new file mode 100644 index 000000000000..64a9eaa83e6a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureAISearchAsyncSample.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.AISearchIndexResource; +import com.azure.ai.agents.persistent.models.AzureAISearchResource; +import com.azure.ai.agents.persistent.models.AzureAISearchToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public final class AgentAzureAISearchAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + String aiSearchConnectionId = Configuration.getGlobalConfiguration().get("AI_SEARCH_CONNECTION_ID", ""); + + ToolResources toolResources = new ToolResources() + .setAzureAISearch(new AzureAISearchResource() + .setIndexList(Arrays.asList(new AISearchIndexResource(aiSearchConnectionId, "azureblob-index")))); + + String agentName = "ai_search_example_async"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(new AzureAISearchToolDefinition())) + .setToolResources(toolResources); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create full reactive chain to showcase reactive programming + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + // Create initial message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "Best horror movie?" + ).flatMap(message -> { + System.out.println("Created initial message"); + + // Create run + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }) + .doFinally(signalType -> { + // Always clean up resources regardless of success or failure + System.out.println("Cleaning up resources..."); + + // Clean up thread if created + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()) + .doOnSuccess(ignored -> System.out.println("Thread deleted: " + threadId.get())) + .doOnError(error -> System.err.println("Failed to delete thread: " + error.getMessage())) + .subscribe(); + } + + // Clean up agent if created + if (agentId.get() != null) { + agentsAsyncClient.deleteAgent(agentId.get()) + .doOnSuccess(ignored -> System.out.println("Agent deleted: " + agentId.get())) + .doOnError(error -> System.err.println("Failed to delete agent: " + error.getMessage())) + .subscribe(); + } + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureAISearchSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureAISearchSample.java new file mode 100644 index 000000000000..523b85715b2e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureAISearchSample.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.AISearchIndexResource; +import com.azure.ai.agents.persistent.models.AzureAISearchResource; +import com.azure.ai.agents.persistent.models.AzureAISearchToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public class AgentAzureAISearchSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String aiSearchConnectionId = Configuration.getGlobalConfiguration().get("AI_SEARCH_CONNECTION_ID", ""); + + ToolResources toolResources = new ToolResources() + .setAzureAISearch(new AzureAISearchResource() + .setIndexList(Arrays.asList(new AISearchIndexResource(aiSearchConnectionId, "azureblob-index")))); + + String agentName = "ai_search_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(new AzureAISearchToolDefinition())) + .setToolResources(toolResources); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "Best horror movie?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureFunctionAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureFunctionAsyncSample.java new file mode 100644 index 000000000000..c127dd00679e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureFunctionAsyncSample.java @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.models.AzureFunctionBinding; +import com.azure.ai.agents.persistent.models.AzureFunctionDefinition; +import com.azure.ai.agents.persistent.models.AzureFunctionStorageQueue; +import com.azure.ai.agents.persistent.models.AzureFunctionToolDefinition; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FunctionDefinition; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public class AgentAzureFunctionAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + String storageQueueUri = Configuration.getGlobalConfiguration().get("STORAGE_QUEUE_URI", ""); + String azureFunctionName = Configuration.getGlobalConfiguration().get("AZURE_FUNCTION_NAME", ""); + + FunctionDefinition fnDef = new FunctionDefinition( + azureFunctionName, + BinaryData.fromObject( + mapOf( + "type", "object", + "properties", mapOf( + "location", + mapOf("type", "string", "description", "The location to look up") + ), + "required", new String[]{"location"} + ) + ) + ); + AzureFunctionDefinition azureFnDef = new AzureFunctionDefinition( + fnDef, + new AzureFunctionBinding(new AzureFunctionStorageQueue(storageQueueUri, "agent-input")), + new AzureFunctionBinding(new AzureFunctionStorageQueue(storageQueueUri, "agent-output")) + ); + AzureFunctionToolDefinition azureFnTool = new AzureFunctionToolDefinition(azureFnDef); + + String agentName = "azure_function_example_async"; + RequestOptions requestOptions = new RequestOptions() + .setHeader(HttpHeaderName.fromString("x-ms-enable-preview"), "true"); + CreateAgentRequest createAgentRequestObj = new CreateAgentRequest("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent. Use the provided function any time " + + "you are asked with the weather of any location") + .setTools(Arrays.asList(azureFnTool)); + BinaryData createAgentRequest = BinaryData.fromObject(createAgentRequestObj); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create full reactive chain to showcase reactive programming + agentsAsyncClient.createAgentWithResponse(createAgentRequest, requestOptions) + .flatMap(response -> { + PersistentAgent agent = response.getValue().toObject(PersistentAgent.class); + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + // Create initial message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What is the weather in Seattle, WA?" + ).flatMap(message -> { + System.out.println("Created initial message"); + + // Create run with the agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }) + .doFinally(signalType -> { + // Always clean up resources regardless of success or failure + System.out.println("Cleaning up resources..."); + + // Clean up thread if created + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()) + .doOnSuccess(ignored -> System.out.println("Thread deleted: " + threadId.get())) + .doOnError(error -> System.err.println("Failed to delete thread: " + error.getMessage())) + .subscribe(); + } + + // Clean up agent if created + if (agentId.get() != null) { + agentsAsyncClient.deleteAgent(agentId.get()) + .doOnSuccess(ignored -> System.out.println("Agent deleted: " + agentId.get())) + .doOnError(error -> System.err.println("Failed to delete agent: " + error.getMessage())) + .subscribe(); + } + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureFunctionSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureFunctionSample.java new file mode 100644 index 000000000000..3e50e4f678b6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentAzureFunctionSample.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.models.AzureFunctionBinding; +import com.azure.ai.agents.persistent.models.AzureFunctionDefinition; +import com.azure.ai.agents.persistent.models.AzureFunctionStorageQueue; +import com.azure.ai.agents.persistent.models.AzureFunctionToolDefinition; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FunctionDefinition; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public class AgentAzureFunctionSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String storageQueueUri = Configuration.getGlobalConfiguration().get("STORAGE_QUEUE_URI", ""); + String azureFunctionName = Configuration.getGlobalConfiguration().get("AZURE_FUNCTION_NAME", ""); + + FunctionDefinition fnDef = new FunctionDefinition( + azureFunctionName, + BinaryData.fromObject( + mapOf( + "type", "object", + "properties", mapOf( + "location", + mapOf("type", "string", "description", "The location to look up") + ), + "required", new String[]{"location"} + ) + ) + ); + AzureFunctionDefinition azureFnDef = new AzureFunctionDefinition( + fnDef, + new AzureFunctionBinding(new AzureFunctionStorageQueue(storageQueueUri, "agent-input")), + new AzureFunctionBinding(new AzureFunctionStorageQueue(storageQueueUri, "agent-output")) + ); + AzureFunctionToolDefinition azureFnTool = new AzureFunctionToolDefinition(azureFnDef); + + String agentName = "azure_function_example"; + RequestOptions requestOptions = new RequestOptions() + .setHeader(HttpHeaderName.fromString("x-ms-enable-preview"), "true"); + CreateAgentRequest createAgentRequestObj = new CreateAgentRequest("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent. Use the provided function any time " + + "you are asked with the weather of any location") + .setTools(Arrays.asList(azureFnTool)); + BinaryData createAgentRequest = BinaryData.fromObject(createAgentRequestObj); + PersistentAgent agent = agentsClient.createAgentWithResponse(createAgentRequest, requestOptions) + .getValue().toObject(PersistentAgent.class); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What is the weather in Seattle, WA?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBasicAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBasicAsyncSample.java new file mode 100644 index 000000000000..550d6c4fa323 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBasicAsyncSample.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CodeInterpreterToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public final class AgentBasicAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + String agentName = "basic_example_async"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(new CodeInterpreterToolDefinition())); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create full reactive chain to showcase reactive programming + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + // Create initial message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "I need to solve the equation `3x + 11 = 14`. Can you help me?" + ).flatMap(message -> { + System.out.println("Created initial message"); + + // Create and start the run + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBasicSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBasicSample.java new file mode 100644 index 000000000000..aa554e2fe20c --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBasicSample.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CodeInterpreterToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public final class AgentBasicSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String agentName = "basic_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(new CodeInterpreterToolDefinition())); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "I need to solve the equation `3x + 11 = 14`. Can you help me?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchAsyncSample.java new file mode 100644 index 000000000000..c0fb6616f0f8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchAsyncSample.java @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.models.BingCustomSearchConfiguration; +import com.azure.ai.agents.persistent.models.BingCustomSearchConfigurationList; +import com.azure.ai.agents.persistent.models.BingCustomSearchToolDefinition; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.ToolConnection; +import com.azure.ai.agents.persistent.models.ToolConnectionList; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public class AgentBingCustomSearchAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + String bingConnectionId = Configuration.getGlobalConfiguration().get("BING_SEARCH_CONNECTION_ID", ""); + String bingConfigurationId = Configuration.getGlobalConfiguration().get("BING_SEARCH_CONFIGURATION_ID", ""); + + ToolConnectionList toolConnectionList = new ToolConnectionList() + .setConnectionList(Arrays.asList(new ToolConnection(bingConnectionId))); + + BingCustomSearchConfiguration searchConfiguration = new BingCustomSearchConfiguration(bingConnectionId, bingConfigurationId); + BingCustomSearchConfigurationList searchConfigurationList = new BingCustomSearchConfigurationList(Arrays.asList(searchConfiguration)); + + BingCustomSearchToolDefinition bingCustomSearchToolDefinition = new BingCustomSearchToolDefinition(searchConfigurationList); + + String agentName = "bing_custom_search_example_async"; + CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(bingCustomSearchToolDefinition)); + + RequestOptions requestOptions = new RequestOptions() + .setHeader("x-ms-enable-preview", "true"); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create full reactive chain + agentsAsyncClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) + .flatMap(response -> { + PersistentAgent agent = response.getValue().toObject(PersistentAgent.class); + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + // Create initial message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "How does wikipedia explain Euler's Identity?" + ).flatMap(message -> { + System.out.println("Created initial message"); + + // Create run + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }) + .doFinally(signalType -> { + // Always clean up resources regardless of success or failure + System.out.println("Cleaning up resources..."); + + // Clean up thread if created + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()) + .doOnSuccess(ignored -> System.out.println("Thread deleted: " + threadId.get())) + .doOnError(error -> System.err.println("Failed to delete thread: " + error.getMessage())) + .subscribe(); + } + + // Clean up agent if created + if (agentId.get() != null) { + agentsAsyncClient.deleteAgent(agentId.get()) + .doOnSuccess(ignored -> System.out.println("Agent deleted: " + agentId.get())) + .doOnError(error -> System.err.println("Failed to delete agent: " + error.getMessage())) + .subscribe(); + } + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchSample.java new file mode 100644 index 000000000000..3bf3fdeee6e6 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchSample.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.models.BingCustomSearchConfiguration; +import com.azure.ai.agents.persistent.models.BingCustomSearchConfigurationList; +import com.azure.ai.agents.persistent.models.BingCustomSearchToolDefinition; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolConnection; +import com.azure.ai.agents.persistent.models.ToolConnectionList; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + + +public class AgentBingCustomSearchSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String bingConnectionId = Configuration.getGlobalConfiguration().get("BING_SEARCH_CONNECTION_ID", ""); + String bingConfigurationId = Configuration.getGlobalConfiguration().get("BING_SEARCH_CONFIGURATION_ID", ""); + + ToolConnectionList toolConnectionList = new ToolConnectionList() + .setConnectionList(Arrays.asList(new ToolConnection(bingConnectionId))); + + BingCustomSearchConfiguration searchConfiguration = new BingCustomSearchConfiguration(bingConnectionId, bingConfigurationId); + BingCustomSearchConfigurationList searchConfigurationList = new BingCustomSearchConfigurationList(Arrays.asList(searchConfiguration)); + + BingCustomSearchToolDefinition bingCustomSearchToolDefinition = new BingCustomSearchToolDefinition(searchConfigurationList); + + String agentName = "bing_custom_search_example"; + CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(bingCustomSearchToolDefinition)); + RequestOptions requestOptions = new RequestOptions() + .setHeader("x-ms-enable-preview", "true"); + PersistentAgent agent = agentsClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) + .getValue().toObject(PersistentAgent.class); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "How does wikipedia explain Euler's Identity?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingAsyncSample.java new file mode 100644 index 000000000000..e5334a0102bc --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingAsyncSample.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.BingGroundingSearchConfiguration; +import com.azure.ai.agents.persistent.models.BingGroundingSearchConfigurationList; +import com.azure.ai.agents.persistent.models.BingGroundingToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.ToolConnection; +import com.azure.ai.agents.persistent.models.ToolConnectionList; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public class AgentBingGroundingAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + String bingConnectionId = Configuration.getGlobalConfiguration().get("BING_CONNECTION_ID", ""); + ToolConnectionList toolConnectionList = new ToolConnectionList() + .setConnectionList(Arrays.asList(new ToolConnection(bingConnectionId))); + + BingGroundingSearchConfiguration searchConfiguration = new BingGroundingSearchConfiguration(bingConnectionId); + BingGroundingSearchConfigurationList searchConfigurationList = new BingGroundingSearchConfigurationList( + Arrays.asList(searchConfiguration)); + + BingGroundingToolDefinition bingGroundingTool = new BingGroundingToolDefinition(searchConfigurationList); + + String agentName = "bing_grounding_example_async"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-35-turbo") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(bingGroundingTool)); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create full reactive chain + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + // Create initial message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "How does wikipedia explain Euler's Identity?" + ).flatMap(message -> { + System.out.println("Created initial message"); + + // Create and start the run + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingSample.java new file mode 100644 index 000000000000..988cae9d868f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingSample.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.BingGroundingSearchConfiguration; +import com.azure.ai.agents.persistent.models.BingGroundingSearchConfigurationList; +import com.azure.ai.agents.persistent.models.BingGroundingToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolConnection; +import com.azure.ai.agents.persistent.models.ToolConnectionList; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public class AgentBingGroundingSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String bingConnectionId = Configuration.getGlobalConfiguration().get("BING_CONNECTION_ID", ""); + ToolConnectionList toolConnectionList = new ToolConnectionList() + .setConnectionList(Arrays.asList(new ToolConnection(bingConnectionId))); + + BingGroundingSearchConfiguration searchConfiguration = new BingGroundingSearchConfiguration(bingConnectionId); + BingGroundingSearchConfigurationList searchConfigurationList = new BingGroundingSearchConfigurationList(Arrays.asList(searchConfiguration)); + + BingGroundingToolDefinition bingGroundingTool = new BingGroundingToolDefinition(searchConfigurationList); + + String agentName = "bing_grounding_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-35-turbo") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(bingGroundingTool)); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "How does wikipedia explain Euler's Identity?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterEnterpriseFileSearchAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterEnterpriseFileSearchAsyncSample.java new file mode 100644 index 000000000000..557b0a20db37 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterEnterpriseFileSearchAsyncSample.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CodeInterpreterToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageAttachment; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.ai.agents.persistent.models.VectorStoreDataSourceAssetType; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public class AgentCodeInterpreterEnterpriseFileSearchAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + String agentName = "code_interpreter_enterprise_file_search_async"; + CodeInterpreterToolDefinition ciTool = new CodeInterpreterToolDefinition(); + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(ciTool)); + + String dataUri = Configuration.getGlobalConfiguration().get("DATA_URI", ""); + VectorStoreDataSource vectorStoreDataSource = new VectorStoreDataSource( + dataUri, VectorStoreDataSourceAssetType.URI_ASSET); + + MessageAttachment messageAttachment = new MessageAttachment( + Arrays.asList(BinaryData.fromObject(ciTool)) + ).setDataSource(vectorStoreDataSource); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create full reactive chain + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + // Create initial message with attachment + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What does the attachment say?", + Arrays.asList(messageAttachment), + null + ).flatMap(message -> { + System.out.println("Created initial message with attachment"); + + // Create and start the run + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterEnterpriseFileSearchSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterEnterpriseFileSearchSample.java new file mode 100644 index 000000000000..2964c31ac097 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterEnterpriseFileSearchSample.java @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CodeInterpreterToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageAttachment; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.ai.agents.persistent.models.VectorStoreDataSourceAssetType; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public class AgentCodeInterpreterEnterpriseFileSearchSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String agentName = "code_interpreter_enterprise_file_search_example"; + CodeInterpreterToolDefinition ciTool = new CodeInterpreterToolDefinition(); + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(ciTool)); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + String dataUri = Configuration.getGlobalConfiguration().get("DATA_URI", ""); + VectorStoreDataSource vectorStoreDataSource = new VectorStoreDataSource( + dataUri, VectorStoreDataSourceAssetType.URI_ASSET); + + MessageAttachment messageAttachment = new MessageAttachment( + Arrays.asList(BinaryData.fromObject(ciTool)) + ).setDataSource(vectorStoreDataSource); + + PersistentAgentThread thread = threadsClient.createThread(); + + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What does the attachment say?", + Arrays.asList(messageAttachment), + null + ); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterFileAttachmentAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterFileAttachmentAsyncSample.java new file mode 100644 index 000000000000..97b3075d366e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterFileAttachmentAsyncSample.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.CodeInterpreterToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.MessageAttachment; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import reactor.core.publisher.Mono; +import java.io.File; +import java.io.FileNotFoundException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public class AgentCodeInterpreterFileAttachmentAsyncSample { + + public static void main(String[] args) { + try { + // Find and get the HTML file + Path htmlFile = getFile("sample.html"); + + // Initialize async clients + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + FilesAsyncClient filesAsyncClient = clientBuilder.buildFilesAsyncClient(); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + AtomicReference fileId = new AtomicReference<>(); + + // Define agent properties + String agentName = "code_interpreter_file_attachment_async_example"; + CodeInterpreterToolDefinition ciTool = new CodeInterpreterToolDefinition(); + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent that analyzes HTML files") + .setTools(Arrays.asList(ciTool)); + + // Create file upload request + UploadFileRequest uploadFileRequest = new UploadFileRequest( + new FileDetails(BinaryData.fromFile(htmlFile)) + .setFilename("sample.html"), + FilePurpose.AGENTS); + + // Build reactive chain + Mono.zip( + agentsAsyncClient.createAgent(createAgentOptions), + filesAsyncClient.uploadFile(uploadFileRequest) + ).flatMap(tuple -> { + // Store resources for cleanup + agentId.set(tuple.getT1().getId()); + fileId.set(tuple.getT2().getId()); + + System.out.println("Created agent: " + tuple.getT1().getId()); + System.out.println("Uploaded file: " + tuple.getT2().getId()); + + // Create message attachment with file reference + MessageAttachment messageAttachment = new MessageAttachment( + Arrays.asList(BinaryData.fromObject(ciTool))) + .setFileId(tuple.getT2().getId()); + + // Create thread + return threadsAsyncClient.createThread() + .flatMap(thread -> { + threadId.set(thread.getId()); + System.out.println("Created thread: " + thread.getId()); + + // Create message with attachment + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What does the attachment say? Analyze the HTML structure and content.", + Arrays.asList(messageAttachment), + null + ).flatMap(message -> { + System.out.println("Created message with attachment"); + + // Create run options + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), tuple.getT1().getId()) + .setAdditionalInstructions("Provide a detailed analysis of the HTML file"); + + // Create run and wait for completion + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }) + .doFinally(signalType -> { + // Clean up resources + System.out.println("Cleaning up resources..."); + cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient); + + // Delete the file if it was created + if (fileId.get() != null) { + filesAsyncClient.deleteFile(fileId.get()).block(); + System.out.println("Deleted file: " + fileId.get()); + } + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } catch (FileNotFoundException | URISyntaxException e) { + System.err.println("Error loading sample file: " + e.getMessage()); + } + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentCodeInterpreterFileAttachmentAsyncSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found: " + fileName); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterFileAttachmentSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterFileAttachmentSample.java new file mode 100644 index 000000000000..33363f4ec3d3 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentCodeInterpreterFileAttachmentSample.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.CodeInterpreterToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.MessageAttachment; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.io.File; +import java.io.FileNotFoundException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public class AgentCodeInterpreterFileAttachmentSample { + + public static void main(String[] args) throws FileNotFoundException, URISyntaxException { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + FilesClient filesClient = clientBuilder.buildFilesClient(); + + Path htmlFile = getFile("sample.html"); + + String agentName = "code_interpreter_file_attachment_example"; + CodeInterpreterToolDefinition ciTool = new CodeInterpreterToolDefinition(); + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini").setName(agentName).setInstructions("You are a helpful agent").setTools(Arrays.asList(ciTool)); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + FileInfo uploadedFile = filesClient.uploadFile(new UploadFileRequest( + new FileDetails(BinaryData.fromFile(htmlFile)) + .setFilename("sample.html"), FilePurpose.AGENTS)); + + MessageAttachment messageAttachment = new MessageAttachment(Arrays.asList(BinaryData.fromObject(ciTool))).setFileId(uploadedFile.getId()); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What does the attachment say?", + Arrays.asList(messageAttachment), + null); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()).setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentCodeInterpreterFileAttachmentSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found"); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentConnectedAgentAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentConnectedAgentAsyncSample.java new file mode 100644 index 000000000000..a15f1f3f0904 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentConnectedAgentAsyncSample.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.models.ConnectedAgentDetails; +import com.azure.ai.agents.persistent.models.ConnectedAgentToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import reactor.core.publisher.Mono; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public final class AgentConnectedAgentAsyncSample { + + public static void main(String[] args) { + // Initialize async clients + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + // Track resources for cleanup + AtomicReference connectedAgentId = new AtomicReference<>(); + AtomicReference mainAgentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Define connected agent properties + String connectedAgentName = "stock_price_bot_async"; + CreateAgentOptions connectedAgentCreateOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(connectedAgentName) + .setInstructions("Your job is to get the stock price of a company. Just return $391.85 EOD 27-Apr-2025"); + + // Create the connected agent first + agentsAsyncClient.createAgent(connectedAgentCreateOptions) + .flatMap(connectedAgent -> { + connectedAgentId.set(connectedAgent.getId()); + System.out.println("Created connected agent: " + connectedAgent.getId()); + + // Create main agent with connected agent tool + ConnectedAgentToolDefinition connectedAgentToolDefinition = new ConnectedAgentToolDefinition( + new ConnectedAgentDetails(connectedAgent.getId(), connectedAgent.getName(), + "Gets the stock price of a company")); + + String mainAgentName = "my-assistant-async"; + CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o-mini") + .setName(mainAgentName) + .setInstructions("You are a helpful assistant, and use the connected agent to get stock prices.") + .setTools(Arrays.asList(connectedAgentToolDefinition)); + + RequestOptions requestOptions = new RequestOptions() + .setHeader("x-ms-enable-preview", "true"); + + return agentsAsyncClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) + .flatMap(response -> { + return Mono.just(response.getValue().toObject(PersistentAgent.class)); + }); + }) + .flatMap(mainAgent -> { + mainAgentId.set(mainAgent.getId()); + System.out.println("Created main agent: " + mainAgent.getId()); + + // Create a thread + return threadsAsyncClient.createThread(); + }) + .flatMap(thread -> { + threadId.set(thread.getId()); + System.out.println("Created thread: " + thread.getId()); + + // Create message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What is the stock price of Microsoft?"); + }) + .flatMap(message -> { + System.out.println("Created message"); + + // Create and start the run + CreateRunOptions createRunOptions = new CreateRunOptions(threadId.get(), mainAgentId.get()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(threadId.get(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, threadId.get()); + }); + }) + .doFinally(signalType -> { + System.out.println("Cleaning up resources..."); + // Clean up the thread + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()).block(); + System.out.println("Deleted thread: " + threadId.get()); + } + + // Clean up the main agent + if (mainAgentId.get() != null) { + agentsAsyncClient.deleteAgent(mainAgentId.get()).block(); + System.out.println("Deleted main agent: " + mainAgentId.get()); + } + + // Clean up the connected agent + if (connectedAgentId.get() != null) { + agentsAsyncClient.deleteAgent(connectedAgentId.get()).block(); + System.out.println("Deleted connected agent: " + connectedAgentId.get()); + } + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentConnectedAgentSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentConnectedAgentSample.java new file mode 100644 index 000000000000..c7f32ebc26db --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentConnectedAgentSample.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.models.ConnectedAgentDetails; +import com.azure.ai.agents.persistent.models.ConnectedAgentToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public final class AgentConnectedAgentSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String connectedAgentName = "stock_price_bot"; + CreateAgentOptions connectedAgentCreateOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(connectedAgentName) + .setInstructions("Your job is to get the stock price of a company. Just return $391.85 EOD 27-Apr-2025"); + PersistentAgent connectedAgent = agentsClient.createAgent(connectedAgentCreateOptions); + + ConnectedAgentToolDefinition connectedAgentToolDefinition = new ConnectedAgentToolDefinition( + new ConnectedAgentDetails(connectedAgent.getId(), connectedAgent.getName(), "Gets the stock price of a company")); + + String agentName = "my-assistant"; + CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful assistant, and use the connected agent to get stock prices.") + .setTools(Arrays.asList(connectedAgentToolDefinition)); + RequestOptions requestOptions = new RequestOptions() + .setHeader("x-ms-enable-preview", "true"); + PersistentAgent agent = agentsClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) + .getValue().toObject(PersistentAgent.class); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What is the stock price of Microsoft?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentEnterpriseFileSearchAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentEnterpriseFileSearchAsyncSample.java new file mode 100644 index 000000000000..df3b8e91363d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentEnterpriseFileSearchAsyncSample.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FileSearchToolDefinition; +import com.azure.ai.agents.persistent.models.FileSearchToolResource; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.ai.agents.persistent.models.VectorStoreConfiguration; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.ai.agents.persistent.models.VectorStoreDataSourceAssetType; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public class AgentEnterpriseFileSearchAsyncSample { + + public static void main(String[] args) { + // Initialize async clients + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + VectorStoresAsyncClient vectorStoresAsyncClient = clientBuilder.buildVectorStoresAsyncClient(); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + AtomicReference vectorStoreId = new AtomicReference<>(); + + // Get data URI from configuration + String dataUri = Configuration.getGlobalConfiguration().get("DATA_URI", ""); + + // Set up vector store data source + VectorStoreDataSource vectorStoreDataSource = new VectorStoreDataSource( + "assistant-6FP6sNAo21Z7pVR2ouGoPp", VectorStoreDataSourceAssetType.URI_ASSET); + + // Create vector store + vectorStoresAsyncClient + .createVectorStore( + null, "sample_vector_store_async", + new VectorStoreConfiguration(Arrays.asList(vectorStoreDataSource)), + null, null, null + ) + .flatMap(vectorStore -> { + vectorStoreId.set(vectorStore.getId()); + System.out.println("Created vector store: " + vectorStore.getId()); + + // Create file search tool resource with the vector store + FileSearchToolResource fileSearchToolResource = new FileSearchToolResource() + .setVectorStoreIds(Arrays.asList(vectorStore.getId())); + + // Create agent options + String agentName = "enterprise_file_search_async_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent specialized in searching through documents") + .setTools(Arrays.asList(new FileSearchToolDefinition())) + .setToolResources(new ToolResources().setFileSearch(fileSearchToolResource)); + + // Create the agent + return agentsAsyncClient.createAgent(createAgentOptions); + }) + .flatMap(agent -> { + agentId.set(agent.getId()); + System.out.println("Created agent: " + agent.getId()); + + // Create a thread + return threadsAsyncClient.createThread(); + }) + .flatMap(thread -> { + threadId.set(thread.getId()); + System.out.println("Created thread: " + thread.getId()); + + // Create message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What is data about? Please search and provide detailed information."); + }) + .flatMap(message -> { + System.out.println("Created message"); + + // Create and start the run + CreateRunOptions createRunOptions = new CreateRunOptions(threadId.get(), agentId.get()) + .setAdditionalInstructions("Provide detailed information from the document search"); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(threadId.get(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, threadId.get()); + }); + }) + .doFinally(signalType -> { + System.out.println("Cleaning up resources..."); + + // Delete thread + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()).block(); + System.out.println("Deleted thread: " + threadId.get()); + } + + // Delete agent + if (agentId.get() != null) { + agentsAsyncClient.deleteAgent(agentId.get()).block(); + System.out.println("Deleted agent: " + agentId.get()); + } + + // Vector stores might need to be cleaned up separately depending on your application + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentEnterpriseFileSearchSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentEnterpriseFileSearchSample.java new file mode 100644 index 000000000000..78973b1d0f55 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentEnterpriseFileSearchSample.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FileSearchToolDefinition; +import com.azure.ai.agents.persistent.models.FileSearchToolResource; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreConfiguration; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.ai.agents.persistent.models.VectorStoreDataSourceAssetType; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public class AgentEnterpriseFileSearchSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + VectorStoresClient vectorStoresClient = clientBuilder.buildVectorStoresClient(); + + String dataUri = Configuration.getGlobalConfiguration().get("DATA_URI", ""); + VectorStoreDataSource vectorStoreDataSource = new VectorStoreDataSource( + "assistant-6FP6sNAo21Z7pVR2ouGoPp", VectorStoreDataSourceAssetType.URI_ASSET); + + VectorStore vs = vectorStoresClient.createVectorStore( + null, "sample_vector_store", + new VectorStoreConfiguration(Arrays.asList(vectorStoreDataSource)), + null, null, null + ); + + FileSearchToolResource fileSearchToolResource = new FileSearchToolResource() + .setVectorStoreIds(Arrays.asList(vs.getId())); + + String agentName = "enterprise_file_search_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(new FileSearchToolDefinition())) + .setToolResources(new ToolResources().setFileSearch(fileSearchToolResource)); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What is data about?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolAsyncSample.java new file mode 100644 index 000000000000..ac5a3cee87e8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolAsyncSample.java @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.MicrosoftFabricToolDefinition; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.ToolConnection; +import com.azure.ai.agents.persistent.models.ToolConnectionList; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public final class AgentFabricToolAsyncSample { + + public static void main(String[] args) { + // Initialize async clients + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Get Fabric connection ID from configuration + String fabricConnectionId = Configuration.getGlobalConfiguration().get("FABRIC_CONNECTION_ID", ""); + System.out.println("Using Fabric connection ID: " + fabricConnectionId); + + // Create tool connections list with Fabric connection + ToolConnectionList toolConnectionList = new ToolConnectionList() + .setConnectionList(Arrays.asList(new ToolConnection(fabricConnectionId))); + + // Create Fabric tool definition + MicrosoftFabricToolDefinition fabricToolDefinition = new MicrosoftFabricToolDefinition(toolConnectionList); + + // Create agent request with Fabric tool + String agentName = "fabric_tool_async_example"; + RequestOptions requestOptions = new RequestOptions().setHeader("x-ms-enable-preview", "true"); + CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent specialized in querying Microsoft Fabric data") + .setTools(Arrays.asList(fabricToolDefinition)); + + // Create agent with Fabric tool + agentsAsyncClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) + .flatMap(response -> { + // Extract agent from response + PersistentAgent agent = + response.getValue().toObject(PersistentAgent.class); + agentId.set(agent.getId()); + System.out.println("Created agent: " + agent.getId()); + + // Create a thread + return threadsAsyncClient.createThread(); + }) + .flatMap(thread -> { + threadId.set(thread.getId()); + System.out.println("Created thread: " + thread.getId()); + + // Create message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "Give me any row from DailyActivity table from connected fabric usage metrics source"); + }) + .flatMap(message -> { + System.out.println("Created message"); + + // Create and start the run + CreateRunOptions createRunOptions = new CreateRunOptions(threadId.get(), agentId.get()) + .setAdditionalInstructions("Please provide detailed information from the Fabric data"); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(threadId.get(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, threadId.get()); + }); + }) + .doFinally(signalType -> { + System.out.println("Cleaning up resources..."); + + // Delete thread + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()).block(); + System.out.println("Deleted thread: " + threadId.get()); + } + + // Delete agent + if (agentId.get() != null) { + agentsAsyncClient.deleteAgent(agentId.get()).block(); + System.out.println("Deleted agent: " + agentId.get()); + } + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolSample.java new file mode 100644 index 000000000000..d52dbe4a461e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolSample.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.MicrosoftFabricToolDefinition; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolConnection; +import com.azure.ai.agents.persistent.models.ToolConnectionList; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public final class AgentFabricToolSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String fabricConnectionId = Configuration.getGlobalConfiguration().get("FABRIC_CONNECTION_ID", ""); + ToolConnectionList toolConnectionList = new ToolConnectionList() + .setConnectionList(Arrays.asList(new ToolConnection(fabricConnectionId))); + MicrosoftFabricToolDefinition fabricToolDefinition = new MicrosoftFabricToolDefinition(toolConnectionList); + + String agentName = "fabric_tool_example"; + RequestOptions requestOptions = new RequestOptions().setHeader("x-ms-enable-preview", "true"); + CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(fabricToolDefinition)); + PersistentAgent agent = agentsClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) + .getValue().toObject(PersistentAgent.class); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "Give me any row from DailyActivity table from connected fabric usage metrics source"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFileSearchAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFileSearchAsyncSample.java new file mode 100644 index 000000000000..04ff75117588 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFileSearchAsyncSample.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.FileSearchToolDefinition; +import com.azure.ai.agents.persistent.models.FileSearchToolResource; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.ai.agents.persistent.models.VectorStoreStatus; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import reactor.core.publisher.Mono; +import java.time.Duration; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public class AgentFileSearchAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + FilesAsyncClient filesAsyncClient = clientBuilder.buildFilesAsyncClient(); + VectorStoresAsyncClient vectorStoresAsyncClient = clientBuilder.buildVectorStoresAsyncClient(); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + AtomicReference vectorStoreId = new AtomicReference<>(); + + // Create full reactive chain + filesAsyncClient.uploadFile( + new UploadFileRequest( + new FileDetails( + BinaryData.fromString("The word `apple` uses the code 442345, while the word `banana` uses the code 673457.")) + .setFilename("sample_file_for_upload.txt"), + FilePurpose.AGENTS)) + .flatMap(uploadedAgentFile -> { + System.out.println("Uploaded file: " + uploadedAgentFile.getId()); + + return vectorStoresAsyncClient.createVectorStore( + Arrays.asList(uploadedAgentFile.getId()), + "my_vector_store", + null, null, null, null); + }) + .flatMap(vectorStore -> { + System.out.println("Created vector store: " + vectorStore.getId()); + vectorStoreId.set(vectorStore.getId()); + + // Poll until vector store is ready + return Mono.fromSupplier(() -> vectorStore) + .expand(vs -> { + if (vs.getStatus() == VectorStoreStatus.IN_PROGRESS) { + return Mono.delay(Duration.ofMillis(500)) + .then(vectorStoresAsyncClient.getVectorStore(vs.getId())); + } else { + return Mono.empty(); + } + }) + .filter(vs -> vs.getStatus() != VectorStoreStatus.IN_PROGRESS) + .last(); + }) + .flatMap(readyVectorStore -> { + System.out.println("Vector store ready with status: " + readyVectorStore.getStatus()); + + FileSearchToolResource fileSearchToolResource = new FileSearchToolResource() + .setVectorStoreIds(Arrays.asList(readyVectorStore.getId())); + + String agentName = "file_search_example_async"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent that can help fetch data from files you know about.") + .setTools(Arrays.asList(new FileSearchToolDefinition())) + .setToolResources(new ToolResources().setFileSearch(fileSearchToolResource)); + + return agentsAsyncClient.createAgent(createAgentOptions); + }) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread(); + }) + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "Can you give me the documented codes for 'banana' and 'orange'?"); + }) + .flatMap(message -> { + System.out.println("Created message"); + + CreateRunOptions createRunOptions = new CreateRunOptions(threadId.get(), agentId.get()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions); + }) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(threadId.get(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, threadId.get()); + }) + .doFinally(signalType -> { + // Clean up resources + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()).block(); + System.out.println("Thread deleted: " + threadId.get()); + } + if (agentId.get() != null) { + agentsAsyncClient.deleteAgent(agentId.get()).block(); + System.out.println("Agent deleted: " + agentId.get()); + } + // Vector stores are not deleted in this sample + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFileSearchSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFileSearchSample.java new file mode 100644 index 000000000000..51b3640f2523 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFileSearchSample.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.FileSearchToolDefinition; +import com.azure.ai.agents.persistent.models.FileSearchToolResource; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreStatus; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public class AgentFileSearchSample { + + public static void main(String[] args) throws InterruptedException { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + FilesClient filesClient = clientBuilder.buildFilesClient(); + VectorStoresClient vectorStoresClient = clientBuilder.buildVectorStoresClient(); + + FileInfo uploadedAgentFile = filesClient.uploadFile( + new UploadFileRequest( + new FileDetails( + BinaryData.fromString("The word `apple` uses the code 442345, while the word `banana` uses the code 673457.")) + .setFilename("sample_file_for_upload.txt"), + FilePurpose.AGENTS)); + + VectorStore vectorStore = vectorStoresClient.createVectorStore( + Arrays.asList(uploadedAgentFile.getId()), + "my_vector_store", + null, null, null, null); + + do { + Thread.sleep(500); + vectorStore = vectorStoresClient.getVectorStore(vectorStore.getId()); + } + while (vectorStore.getStatus() == VectorStoreStatus.IN_PROGRESS); + + FileSearchToolResource fileSearchToolResource = new FileSearchToolResource() + .setVectorStoreIds(Arrays.asList(vectorStore.getId())); + + String agentName = "file_search_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent that can help fetch data from files you know about.") + .setTools(Arrays.asList(new FileSearchToolDefinition())) + .setToolResources(new ToolResources().setFileSearch(fileSearchToolResource)); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "Can you give me the documented codes for 'banana' and 'orange'?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsAsyncSample.java new file mode 100644 index 000000000000..41ec0bdb1007 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsAsyncSample.java @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FunctionDefinition; +import com.azure.ai.agents.persistent.models.FunctionToolDefinition; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.RequiredFunctionToolCall; +import com.azure.ai.agents.persistent.models.RequiredToolCall; +import com.azure.ai.agents.persistent.models.RunStatus; +import com.azure.ai.agents.persistent.models.SubmitToolOutputsAction; +import com.azure.ai.agents.persistent.models.ToolOutput; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.json.JsonMapper; +import reactor.core.publisher.Mono; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; +import java.util.function.Supplier; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; + +public class AgentFunctionsAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Define the functions + Supplier getUserFavoriteCity = () -> "Seattle, WA"; + FunctionToolDefinition getUserFavoriteCityTool = new FunctionToolDefinition( + new FunctionDefinition( + "getUserFavoriteCity", + BinaryData.fromObject(new Object()) + ) + ); + + Function getCityNickname = location -> "The Emerald City"; + FunctionToolDefinition getCityNicknameTool = new FunctionToolDefinition( + new FunctionDefinition( + "getCityNickname", + BinaryData.fromObject( + mapOf( + "type", "object", + "properties", mapOf( + "location", + mapOf( + "type", "string", + "description", "The city and state, e.g. San Francisco, CA") + ), + "required", new String[]{"location"})) + ).setDescription("Get the nickname of a city") + ); + + Function getResolvedToolOutput = toolCall -> { + if (toolCall instanceof RequiredFunctionToolCall) { + RequiredFunctionToolCall functionToolCall = (RequiredFunctionToolCall) toolCall; + String functionName = functionToolCall.getFunction().getName(); + if (functionName.equals("getUserFavoriteCity")) { + return new ToolOutput().setToolCallId(functionToolCall.getId()) + .setOutput(getUserFavoriteCity.get()); + } else if (functionName.equals("getCityNickname")) { + String arguments = functionToolCall.getFunction().getArguments(); + try { + JsonNode root = new JsonMapper().readTree(arguments); + String location = String.valueOf(root.get("location").asText()); + return new ToolOutput().setToolCallId(functionToolCall.getId()) + .setOutput(getCityNickname.apply(location)); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + } + return null; + }; + + // Create full reactive chain + String agentName = "functions_example_async"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a weather bot. Use the provided functions to help answer questions. " + + "Customize your responses to the user's preferences as much as possible and use friendly " + + "nicknames for cities whenever possible.") + .setTools(Arrays.asList(getUserFavoriteCityTool, getCityNicknameTool)); + + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread(); + }) + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What's the nickname of my favorite city?"); + }) + .flatMap(message -> { + System.out.println("Created message"); + + CreateRunOptions createRunOptions = new CreateRunOptions(threadId.get(), agentId.get()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions); + }) + .flatMap(threadRun -> { + System.out.println("Created run, monitoring for completion or required actions..."); + + // Poll the run until it's completed + return Mono.fromSupplier(() -> threadRun) + .expand(run -> { + if (run.getStatus() == RunStatus.QUEUED + || run.getStatus() == RunStatus.IN_PROGRESS) { + return Mono.delay(java.time.Duration.ofMillis(500)) + .then(runsAsyncClient.getRun(threadId.get(), run.getId())); + } else if (run.getStatus() == RunStatus.REQUIRES_ACTION) { + // Handle function calls + if (run.getRequiredAction() instanceof SubmitToolOutputsAction) { + SubmitToolOutputsAction submitToolsOutputAction = + (SubmitToolOutputsAction) run.getRequiredAction(); + + ArrayList toolOutputs = new ArrayList<>(); + for (RequiredToolCall toolCall + : submitToolsOutputAction.getSubmitToolOutputs().getToolCalls()) { + toolOutputs.add(getResolvedToolOutput.apply(toolCall)); + } + + return runsAsyncClient.submitToolOutputsToRun( + threadId.get(), run.getId(), toolOutputs) + .flatMap(updatedRun -> Mono.delay(java.time.Duration.ofMillis(500)) + .then(runsAsyncClient.getRun(threadId.get(), updatedRun.getId()))); + } + return Mono.empty(); + } else { + return Mono.empty(); + } + }) + .last(); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + + if (completedRun.getStatus() == RunStatus.FAILED && completedRun.getLastError() != null) { + System.out.println("Run failed: " + completedRun.getLastError().getMessage()); + } + + return printRunMessagesAsync(messagesAsyncClient, threadId.get()); + }) + .doFinally(signalType -> { + // Clean up resources + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()).block(); + System.out.println("Thread deleted: " + threadId.get()); + } + if (agentId.get() != null) { + agentsAsyncClient.deleteAgent(agentId.get()).block(); + System.out.println("Agent deleted: " + agentId.get()); + } + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsSample.java new file mode 100644 index 000000000000..695b68e6c4f7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsSample.java @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FunctionDefinition; +import com.azure.ai.agents.persistent.models.FunctionToolDefinition; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.RequiredFunctionToolCall; +import com.azure.ai.agents.persistent.models.RequiredToolCall; +import com.azure.ai.agents.persistent.models.RunStatus; +import com.azure.ai.agents.persistent.models.SubmitToolOutputsAction; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolOutput; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.json.JsonMapper; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Supplier; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; + +public class AgentFunctionsSample { + + public static void main(String[] args) { + + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + Supplier getUserFavoriteCity = () -> "Seattle, WA"; + FunctionToolDefinition getUserFavoriteCityTool = new FunctionToolDefinition( + new FunctionDefinition( + "getUserFavoriteCity", + BinaryData.fromObject( + new Object() + )) + ); + + Function getCityNickname = location -> { + return "The Emerald City"; + }; + + FunctionToolDefinition getCityNicknameTool = new FunctionToolDefinition( + new FunctionDefinition( + "getCityNickname", + BinaryData.fromObject( + mapOf( + "type", "object", + "properties", mapOf( + "location", + mapOf( + "type", "string", + "description", "The city and state, e.g. San Francisco, CA") + ), + "required", new String[]{"location"})) + ).setDescription("Get the nickname of a city") + ); + + Function getResolvedToolOutput = toolCall -> { + if (toolCall instanceof RequiredFunctionToolCall) { + RequiredFunctionToolCall functionToolCall = (RequiredFunctionToolCall) toolCall; + String functionName = functionToolCall.getFunction().getName(); + if (functionName.equals("getUserFavoriteCity")) { + return new ToolOutput().setToolCallId(functionToolCall.getId()) + .setOutput(getUserFavoriteCity.get()); + } else if (functionName.equals("getCityNickname")) { + String arguments = functionToolCall.getFunction().getArguments(); + try { + JsonNode root = new JsonMapper().readTree(arguments); + String location = String.valueOf(root.get("location").asText()); + return new ToolOutput().setToolCallId(functionToolCall.getId()) + .setOutput(getCityNickname.apply(location)); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + } + return null; + }; + + String agentName = "functions_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a weather bot. Use the provided functions to help answer questions. " + + "Customize your responses to the user's preferences as much as possible and use friendly " + + "nicknames for cities whenever possible.") + .setTools(Arrays.asList(getUserFavoriteCityTool, getCityNicknameTool)); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What's the nickname of my favorite city?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + do { + Thread.sleep(500); + threadRun = runsClient.getRun(thread.getId(), threadRun.getId()); + if (threadRun.getStatus() == RunStatus.REQUIRES_ACTION + && threadRun.getRequiredAction() instanceof SubmitToolOutputsAction) { + SubmitToolOutputsAction submitToolsOutputAction = (SubmitToolOutputsAction) (threadRun.getRequiredAction()); + ArrayList toolOutputs = new ArrayList(); + for (RequiredToolCall toolCall : submitToolsOutputAction.getSubmitToolOutputs().getToolCalls()) { + toolOutputs.add(getResolvedToolOutput.apply(toolCall)); + } + threadRun = runsClient.submitToolOutputsToRun(thread.getId(), threadRun.getId(), toolOutputs); + } + } + while ( + threadRun.getStatus() == RunStatus.QUEUED + || threadRun.getStatus() == RunStatus.IN_PROGRESS + || threadRun.getStatus() == RunStatus.REQUIRES_ACTION); + + if (threadRun.getStatus() == RunStatus.FAILED) { + System.out.println(threadRun.getLastError().getMessage()); + } + + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingAsyncSample.java new file mode 100644 index 000000000000..584b8f97e3a7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingAsyncSample.java @@ -0,0 +1,255 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FunctionDefinition; +import com.azure.ai.agents.persistent.models.FunctionToolDefinition; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.ai.agents.persistent.models.RequiredFunctionToolCall; +import com.azure.ai.agents.persistent.models.RequiredToolCall; +import com.azure.ai.agents.persistent.models.RunStatus; +import com.azure.ai.agents.persistent.models.SubmitToolOutputsAction; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolOutput; +import com.azure.ai.agents.persistent.models.streaming.StreamMessageUpdate; +import com.azure.ai.agents.persistent.models.streaming.StreamRequiredAction; +import com.azure.ai.agents.persistent.models.streaming.StreamThreadRunCreation; +import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.json.JsonMapper; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printStreamUpdate; + +public final class AgentFunctionsStreamingAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + // function tool definitions + FunctionToolDefinition getUserFavoriteCityTool = new FunctionToolDefinition( + new FunctionDefinition( + "getUserFavoriteCity", + BinaryData.fromObject( + new Object() + )).setDescription("Gets the user's favorite city.") + ); + + FunctionToolDefinition getCityNicknameTool = new FunctionToolDefinition( + new FunctionDefinition( + "getCityNickname", + BinaryData.fromObject( + mapOf( + "type", "object", + "properties", mapOf( + "location", mapOf( + "type", "string", + "description", "The city and state, e.g. San Francisco, CA") + ), + "required", new String[]{"location"})) + ).setDescription("Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.") + ); + + FunctionToolDefinition getCurrentWeatherAtLocationTool = new FunctionToolDefinition( + new FunctionDefinition( + "getCurrentWeatherAtLocation", + BinaryData.fromObject( + mapOf( + "type", "object", + "properties", mapOf( + "location", mapOf( + "type", "string", + "description", "The city and state, e.g. San Francisco, CA"), + "unit", mapOf( + "type", "string", + "description", "temperature unit as c or f", + "enum", new String[]{"c", "f"})), + "required", new String[]{"location", "unit"})) + ).setDescription("Gets the current weather at a provided location.") + ); + + // actual functions + Supplier getUserFavoriteCity = () -> "Seattle, WA"; + + Function getCityNickname = (location) -> { + switch (location) { + case "Seattle, WA": + return "The Emerald city"; + default: + return "No nickname available"; + } + }; + + BiFunction getCurrentWeatherAtLocation = (location, unit) -> { + switch (location) { + case "Seattle, WA": + return unit.equals("f") ? "70f" : "21c"; + default: + return "unknown"; + } + }; + + // function resolver + Function getResolvedToolOutput = toolCall -> { + if (toolCall instanceof RequiredFunctionToolCall) { + try { + RequiredFunctionToolCall functionToolCall = (RequiredFunctionToolCall) toolCall; + String functionName = functionToolCall.getFunction().getName(); + if (functionName.equals("getUserFavoriteCity")) { + return new ToolOutput().setToolCallId(functionToolCall.getId()) + .setOutput(getUserFavoriteCity.get()); + } else if (functionName.equals("getCityNickname")) { + String funcArgs = functionToolCall.getFunction().getArguments(); + + JsonNode root = new JsonMapper().readTree(funcArgs); + String location = String.valueOf(root.get("location").asText()); + return new ToolOutput().setToolCallId(functionToolCall.getId()) + .setOutput(getCityNickname.apply(location)); + + } else if (functionName.equals("getCurrentWeatherAtLocation")) { + String funcArgs = functionToolCall.getFunction().getArguments(); + + JsonNode root = new JsonMapper().readTree(funcArgs); + String location = String.valueOf(root.get("location").asText()); + String unit = String.valueOf(root.get("unit").asText()); + return new ToolOutput().setToolCallId(functionToolCall.getId()) + .setOutput(getCurrentWeatherAtLocation.apply(location, unit)); + } + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + return null; + }; + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + String agentName = "functions_streaming_async_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a weather bot. Use the provided functions to help answer questions. " + + "Customize your responses to the user's preferences as much as possible and use friendly " + + "nicknames for cities whenever possible.") + .setTools(Arrays.asList(getUserFavoriteCityTool, getCityNicknameTool, getCurrentWeatherAtLocationTool)); + + // Create a fully reactive chain + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What's the weather like in my favorite city?") + .flatMap(message -> { + System.out.println("Created initial message"); + + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + System.out.println("----- Run started! -----"); + return runsAsyncClient.createRunStreaming(createRunOptions) + .map(su -> handleStreamingRun(su, runsAsyncClient, getResolvedToolOutput)); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } + + private static Mono handleStreamingRun( + Flux streamingUpdates, + RunsAsyncClient runsAsyncClient, + Function toolOutputResolver) { + + AtomicReference currentRun = new AtomicReference<>(); + + return streamingUpdates + .flatMap(streamUpdate -> { + if (streamUpdate instanceof StreamRequiredAction) { + StreamRequiredAction actionUpdate = (StreamRequiredAction) streamUpdate; + currentRun.set(actionUpdate.getMessage()); + + if (currentRun.get().getStatus() == RunStatus.REQUIRES_ACTION) { + return handleToolActions( + currentRun.get(), + runsAsyncClient, + toolOutputResolver); + } + } else if (streamUpdate instanceof StreamMessageUpdate) { + StreamMessageUpdate messageUpdate = (StreamMessageUpdate) streamUpdate; + printStreamUpdate(messageUpdate); + } else if (streamUpdate.getKind() == PersistentAgentStreamEvent.THREAD_RUN_COMPLETED) { + StreamThreadRunCreation runCreation = (StreamThreadRunCreation) streamUpdate; + currentRun.set(runCreation.getMessage()); + System.out.println("Run completed with status: " + currentRun.get().getStatus()); + } + return Mono.empty(); + }) + .then(); + } + + private static Flux handleToolActions( + ThreadRun run, + RunsAsyncClient runsAsyncClient, + Function toolOutputResolver) { + + List toolOutputs = new ArrayList<>(); + SubmitToolOutputsAction submitAction = (SubmitToolOutputsAction) run.getRequiredAction(); + + for (RequiredToolCall toolCall : submitAction.getSubmitToolOutputs().getToolCalls()) { + toolOutputs.add(toolOutputResolver.apply(toolCall)); + } + + return runsAsyncClient.submitToolOutputsToRunStreaming( + run.getThreadId(), + run.getId(), + toolOutputs).flatMapMany(su -> su); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java new file mode 100644 index 000000000000..7152bc3aaf0f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FunctionDefinition; +import com.azure.ai.agents.persistent.models.FunctionToolDefinition; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.RequiredFunctionToolCall; +import com.azure.ai.agents.persistent.models.RequiredToolCall; +import com.azure.ai.agents.persistent.models.RunStatus; +import com.azure.ai.agents.persistent.models.SubmitToolOutputsAction; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolOutput; +import com.azure.ai.agents.persistent.models.streaming.StreamMessageUpdate; +import com.azure.ai.agents.persistent.models.streaming.StreamRequiredAction; +import com.azure.ai.agents.persistent.models.streaming.StreamThreadRunCreation; +import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.json.JsonMapper; +import reactor.core.publisher.Flux; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; + +import static com.azure.ai.agents.persistent.SampleUtils.printStreamUpdate; + +public final class AgentFunctionsStreamingSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + // function tool definitions + FunctionToolDefinition getUserFavoriteCityTool = new FunctionToolDefinition( + new FunctionDefinition( + "getUserFavoriteCity", + BinaryData.fromObject( + new Object() + )).setDescription("Gets the user's favorite city.") + ); + + FunctionToolDefinition getCityNicknameTool = new FunctionToolDefinition( + new FunctionDefinition( + "getCityNickname", + BinaryData.fromObject( + mapOf( + "type", "object", + "properties", mapOf( + "location", mapOf( + "type", "string", + "description", "The city and state, e.g. San Francisco, CA") + ), + "required", new String[]{"location"})) + ).setDescription("Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.") + ); + + FunctionToolDefinition getCurrentWeatherAtLocationTool = new FunctionToolDefinition( + new FunctionDefinition( + "getCurrentWeatherAtLocation", + BinaryData.fromObject( + mapOf( + "type", "object", + "properties", mapOf( + "location", mapOf( + "type", "string", + "description", "The city and state, e.g. San Francisco, CA"), + "unit", mapOf( + "type", "string", + "description", "temperature unit as c or f", + "enum", new String[]{"c", "f"})), + "required", new String[]{"location", "unit"})) + ).setDescription("Gets the current weather at a provided location.") + ); + + // actual functions + Supplier getUserFavoriteCity = () -> "Seattle, WA"; + + Function getCityNickname = (location) -> { + switch (location) { + case "Seattle, WA": + return "The Emerald city"; + default: + return "No nickname available"; + } + }; + + BiFunction getCurrentWeatherAtLocation = (location, unit) -> { + switch (location) { + case "Seattle, WA": + return unit == "f" ? "70f" : "21c"; + default: + return "unknown"; + } + }; + + // function resolver + Function getResolvedToolOutput = toolCall -> { + if (toolCall instanceof RequiredFunctionToolCall) { + try { + RequiredFunctionToolCall functionToolCall = (RequiredFunctionToolCall) toolCall; + String functionName = functionToolCall.getFunction().getName(); + if (functionName.equals("getUserFavoriteCity")) { + return new ToolOutput().setToolCallId(functionToolCall.getId()) + .setOutput(getUserFavoriteCity.get()); + } else if (functionName.equals("getCityNickname")) { + String funcArgs = functionToolCall.getFunction().getArguments(); + + JsonNode root = new JsonMapper().readTree(funcArgs); + String location = String.valueOf(root.get("location").asText()); + return new ToolOutput().setToolCallId(functionToolCall.getId()) + .setOutput(getCityNickname.apply(location)); + + } else if (functionName.equals("getCurrentWeatherAtLocation")) { + String funcArgs = functionToolCall.getFunction().getArguments(); + + JsonNode root = new JsonMapper().readTree(funcArgs); + String location = String.valueOf(root.get("location").asText()); + String unit = String.valueOf(root.get("unit").asText()); + return new ToolOutput().setToolCallId(functionToolCall.getId()) + .setOutput(getCurrentWeatherAtLocation.apply(location, unit)); + } + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + } + return null; + }; + + String agentName = "functions_streaming_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a weather bot. Use the provided functions to help answer questions. " + + "Customize your responses to the user's preferences as much as possible and use friendly " + + "nicknames for cities whenever possible.") + .setTools(Arrays.asList(getUserFavoriteCityTool, getCityNicknameTool, getCurrentWeatherAtLocationTool)); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What's the weather like in my favorite city?"); + + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + try { + Flux streamingUpdates = runsClient.createRunStreaming(createRunOptions); + + + streamingUpdates.doOnNext( + streamUpdate -> { + if (streamUpdate.getKind() == PersistentAgentStreamEvent.THREAD_RUN_CREATED) { + System.out.println("----- Run started! -----"); + } else if (streamUpdate instanceof StreamRequiredAction) { + StreamRequiredAction actionUpdate = (StreamRequiredAction) streamUpdate; + AtomicReference streamRun = new AtomicReference<>(actionUpdate.getMessage()); + + while (streamRun.get().getStatus() == RunStatus.REQUIRES_ACTION) { + List toolOutputs = new ArrayList<>(); + + SubmitToolOutputsAction submitToolsOutputAction = (SubmitToolOutputsAction) (streamRun.get().getRequiredAction()); + for (RequiredToolCall toolCall : submitToolsOutputAction.getSubmitToolOutputs().getToolCalls()) { + toolOutputs.add(getResolvedToolOutput.apply(toolCall)); + } + + runsClient.submitToolOutputsToRunStreaming( + streamRun.get().getThreadId(), + streamRun.get().getId(), + toolOutputs + ).doOnNext(update -> { + if (update instanceof StreamRequiredAction) { + streamRun.set(((StreamRequiredAction) update).getMessage()); + } else if (update instanceof StreamMessageUpdate) { + StreamMessageUpdate messageUpdate = (StreamMessageUpdate) update; + printStreamUpdate(messageUpdate); + } else if (update.getKind() == PersistentAgentStreamEvent.THREAD_RUN_COMPLETED) { + streamRun.set(((StreamThreadRunCreation) update).getMessage()); + } + }).blockLast(); + } + } else if (streamUpdate instanceof StreamMessageUpdate) { + StreamMessageUpdate messageUpdate = (StreamMessageUpdate) streamUpdate; + printStreamUpdate(messageUpdate); + } + } + ).blockLast(); + + System.out.println(); + } catch (Exception ex) { + throw ex; + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputBase64AsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputBase64AsyncSample.java new file mode 100644 index 000000000000..4843ae27797f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputBase64AsyncSample.java @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageImageUrlParam; +import com.azure.ai.agents.persistent.models.MessageInputContentBlock; +import com.azure.ai.agents.persistent.models.MessageInputImageUrlBlock; +import com.azure.ai.agents.persistent.models.MessageInputTextBlock; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Base64; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public final class AgentImageInputBase64AsyncSample { + + public static void main(String[] args) throws IOException, URISyntaxException { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Prepare the image + Path file = getFile("sample_image.jpg"); + byte[] imageContent = Files.readAllBytes(file); + String imageBase64 = Base64.getEncoder().encodeToString(imageContent); + String imageUrl = "data:image/png;base64," + imageBase64; + + List messageBlock = Arrays.asList( + new MessageInputTextBlock("Hello, what is in the image"), + new MessageInputImageUrlBlock(new MessageImageUrlParam(imageUrl)) + ); + + // Create full reactive chain + String agentName = "image_input_example_async"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent"); + + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread(); + }) + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + BinaryData.fromObject(messageBlock)); + }) + .flatMap(message -> { + System.out.println("Created message with image"); + + CreateRunOptions createRunOptions = new CreateRunOptions(threadId.get(), agentId.get()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions); + }) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(threadId.get(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, threadId.get()); + }) + .doFinally(signalType -> { + // Clean up resources + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()).block(); + System.out.println("Thread deleted: " + threadId.get()); + } + if (agentId.get() != null) { + agentsAsyncClient.deleteAgent(agentId.get()).block(); + System.out.println("Agent deleted: " + agentId.get()); + } + }) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentCodeInterpreterFileAttachmentSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found"); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputBase64Sample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputBase64Sample.java new file mode 100644 index 000000000000..83964732f0ec --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputBase64Sample.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageImageUrlParam; +import com.azure.ai.agents.persistent.models.MessageInputContentBlock; +import com.azure.ai.agents.persistent.models.MessageInputImageUrlBlock; +import com.azure.ai.agents.persistent.models.MessageInputTextBlock; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Base64; +import java.util.List; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public final class AgentImageInputBase64Sample { + + public static void main(String[] args) throws IOException, URISyntaxException { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + Path file = getFile("sample_image.jpg"); + byte[] imageContent = Files.readAllBytes(file); + String imageBase64 = Base64.getEncoder().encodeToString(imageContent); + String imageUrl = "data:image/png;base64," + imageBase64; + + List messageBlock = Arrays.asList(new MessageInputTextBlock("Hello, what is in the image"), + new MessageInputImageUrlBlock(new MessageImageUrlParam(imageUrl))); + + String agentName = "image_input_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent"); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + BinaryData.fromObject(messageBlock)); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentCodeInterpreterFileAttachmentSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found"); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputFileAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputFileAsyncSample.java new file mode 100644 index 000000000000..5c115af53b01 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputFileAsyncSample.java @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.MessageImageFileParam; +import com.azure.ai.agents.persistent.models.MessageInputContentBlock; +import com.azure.ai.agents.persistent.models.MessageInputImageFileBlock; +import com.azure.ai.agents.persistent.models.MessageInputTextBlock; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import reactor.core.publisher.Mono; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public final class AgentImageInputFileAsyncSample { + + public static void main(String[] args) throws IOException, URISyntaxException { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + FilesAsyncClient filesAsyncClient = clientBuilder.buildFilesAsyncClient(); + + Path file = getFile("sample_image.jpg"); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create full reactive chain + Mono uploadFileMono = filesAsyncClient.uploadFile( + new UploadFileRequest( + new FileDetails( + BinaryData.fromFile(file)) + .setFilename("sample_image.jpg"), + FilePurpose.AGENTS)); + + uploadFileMono + .flatMap(uploadedAgentFile -> { + MessageImageFileParam fileParam = new MessageImageFileParam(uploadedAgentFile.getId()); + List messageBlock = Arrays.asList( + new MessageInputTextBlock("Hello, what is in the image"), + new MessageInputImageFileBlock(fileParam)); + + String agentName = "image_input_async_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o") + .setName(agentName) + .setInstructions("You are a helpful agent"); + + return agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + BinaryData.fromObject(messageBlock)) + .flatMap(message -> { + System.out.println("Created message with image file"); + + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentCodeInterpreterFileAttachmentSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found"); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputFileSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputFileSample.java new file mode 100644 index 000000000000..f14b6e709629 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputFileSample.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.MessageImageFileParam; +import com.azure.ai.agents.persistent.models.MessageInputContentBlock; +import com.azure.ai.agents.persistent.models.MessageInputImageFileBlock; +import com.azure.ai.agents.persistent.models.MessageInputTextBlock; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public final class AgentImageInputFileSample { + + public static void main(String[] args) throws IOException, URISyntaxException { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + FilesClient filesClient = clientBuilder.buildFilesClient(); + + Path file = getFile("sample_image.jpg"); + + FileInfo uploadedAgentFile = filesClient.uploadFile( + new UploadFileRequest( + new FileDetails( + BinaryData.fromFile(file)) + .setFilename("sample_image.jpg"), + FilePurpose.AGENTS)); + + MessageImageFileParam fileParam = new MessageImageFileParam(uploadedAgentFile.getId()); + + List messageBlock = Arrays.asList(new MessageInputTextBlock("Hello, what is in the image"), + new MessageInputImageFileBlock(fileParam)); + + String agentName = "image_input_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o") + .setName(agentName) + .setInstructions("You are a helpful agent"); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + BinaryData.fromObject(messageBlock)); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentCodeInterpreterFileAttachmentSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found"); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputUrlAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputUrlAsyncSample.java new file mode 100644 index 000000000000..ec4f72dafdea --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputUrlAsyncSample.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageImageUrlParam; +import com.azure.ai.agents.persistent.models.MessageInputContentBlock; +import com.azure.ai.agents.persistent.models.MessageInputImageUrlBlock; +import com.azure.ai.agents.persistent.models.MessageInputTextBlock; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public final class AgentImageInputUrlAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + String imageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"; + + List messageBlock = Arrays.asList( + new MessageInputTextBlock("Hello, what is in the image"), + new MessageInputImageUrlBlock(new MessageImageUrlParam(imageUrl))); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + String agentName = "image_url_async_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent"); + + // Create full reactive chain + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + BinaryData.fromObject(messageBlock)) + .flatMap(message -> { + System.out.println("Created message with image URL"); + + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputUrlSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputUrlSample.java new file mode 100644 index 000000000000..32963500a843 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentImageInputUrlSample.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageImageUrlParam; +import com.azure.ai.agents.persistent.models.MessageInputContentBlock; +import com.azure.ai.agents.persistent.models.MessageInputImageUrlBlock; +import com.azure.ai.agents.persistent.models.MessageInputTextBlock; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public final class AgentImageInputUrlSample { + + public static void main(String[] args) throws IOException, URISyntaxException { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String imageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"; + + List messageBlock = Arrays.asList(new MessageInputTextBlock("Hello, what is in the image"), + new MessageInputImageUrlBlock(new MessageImageUrlParam(imageUrl))); + + String agentName = "image_input_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent"); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + BinaryData.fromObject(messageBlock)); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentCodeInterpreterFileAttachmentSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found"); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentListThreadAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentListThreadAsyncSample.java new file mode 100644 index 000000000000..ee1bf6a18efe --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentListThreadAsyncSample.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class AgentListThreadAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + + System.out.println("Listing threads asynchronously:"); + + threadsAsyncClient.listThreads() + .doOnNext(thread -> System.out.printf("Found thread ID: %s%n", thread.getId())) + .doOnComplete(() -> System.out.println("Completed listing all threads")) + .doOnError(error -> System.err.println("Error occurred: " + error.getMessage())) + .blockLast(); // Block until all threads are processed + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentListThreadSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentListThreadSample.java new file mode 100644 index 000000000000..ebef3a64c95e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentListThreadSample.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; + +public class AgentListThreadSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + + PagedIterable threads = threadsClient.listThreads(); + for (PersistentAgentThread thread : threads) { + System.out.printf("Found thread ID: %s%n", thread.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentOpenApiAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentOpenApiAsyncSample.java new file mode 100644 index 000000000000..88355eb83e07 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentOpenApiAsyncSample.java @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.OpenApiAnonymousAuthDetails; +import com.azure.ai.agents.persistent.models.OpenApiFunctionDefinition; +import com.azure.ai.agents.persistent.models.OpenApiToolDefinition; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.json.JsonProviders; +import com.azure.json.JsonReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public final class AgentOpenApiAsyncSample { + + public static void main(String[] args) throws IOException, URISyntaxException { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + Path filePath = getFile("weather_openapi.json"); + JsonReader reader = JsonProviders.createReader(Files.readAllBytes(filePath)); + + OpenApiAnonymousAuthDetails oaiAuth = new OpenApiAnonymousAuthDetails(); + OpenApiToolDefinition openApiTool = new OpenApiToolDefinition(new OpenApiFunctionDefinition( + "openapitool", + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())), + oaiAuth + )); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + String agentName = "openAPI_async_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(openApiTool)); + + // Create full reactive chain + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What's the weather in seattle?") + .flatMap(message -> { + System.out.println("Created message asking about weather"); + + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentOpenApiSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found"); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentOpenApiSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentOpenApiSample.java new file mode 100644 index 000000000000..fd30cfff21bf --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentOpenApiSample.java @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.OpenApiAnonymousAuthDetails; +import com.azure.ai.agents.persistent.models.OpenApiFunctionDefinition; +import com.azure.ai.agents.persistent.models.OpenApiToolDefinition; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.json.JsonProviders; +import com.azure.json.JsonReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public class AgentOpenApiSample { + + public static void main(String[] args) throws IOException, URISyntaxException { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + Path filePath = getFile("weather_openapi.json"); + JsonReader reader = JsonProviders.createReader(Files.readAllBytes(filePath)); + + OpenApiAnonymousAuthDetails oaiAuth = new OpenApiAnonymousAuthDetails(); + OpenApiToolDefinition openApiTool = new OpenApiToolDefinition(new OpenApiFunctionDefinition( + "openapitool", + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())), + oaiAuth + )); + + String agentName = "openAPI_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(openApiTool)); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What's the weather in seattle?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentOpenApiSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found"); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolAsyncSample.java new file mode 100644 index 000000000000..7739ce9517e3 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolAsyncSample.java @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.MicrosoftFabricToolDefinition; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.ToolConnection; +import com.azure.ai.agents.persistent.models.ToolConnectionList; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public final class AgentSharepointToolAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + String sharepointConnectionId = Configuration.getGlobalConfiguration().get("SHAREPOINT_CONNECTION_ID", ""); + ToolConnectionList toolConnectionList = new ToolConnectionList() + .setConnectionList(Arrays.asList(new ToolConnection(sharepointConnectionId))); + MicrosoftFabricToolDefinition fabricToolDefinition = new MicrosoftFabricToolDefinition(toolConnectionList); + + String agentName = "sharepoint_tool_async_example"; + RequestOptions requestOptions = new RequestOptions().setHeader("x-ms-enable-preview", "true"); + CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(fabricToolDefinition)); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create full reactive chain + agentsAsyncClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) + .map(response -> { + PersistentAgent agent = response.getValue().toObject(PersistentAgent.class); + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + return agent; + }) + .flatMap(agent -> threadsAsyncClient.createThread()) + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + // Create initial message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "Give me summary of the document in the sharepoint site" + ).flatMap(message -> { + System.out.println("Created initial message"); + + // Create and start the run + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agentId.get()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolSample.java new file mode 100644 index 000000000000..f09e61bb50bc --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolSample.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.MicrosoftFabricToolDefinition; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolConnection; +import com.azure.ai.agents.persistent.models.ToolConnectionList; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public final class AgentSharepointToolSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String sharepointConnectionId = Configuration.getGlobalConfiguration().get("SHAREPOINT_CONNECTION_ID", ""); + ToolConnectionList toolConnectionList = new ToolConnectionList() + .setConnectionList(Arrays.asList(new ToolConnection(sharepointConnectionId))); + MicrosoftFabricToolDefinition fabricToolDefinition = new MicrosoftFabricToolDefinition(toolConnectionList); + + String agentName = "sharepoint_tool_example"; + RequestOptions requestOptions = new RequestOptions().setHeader("x-ms-enable-preview", "true"); + CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(fabricToolDefinition)); + PersistentAgent agent = agentsClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) + .getValue().toObject(PersistentAgent.class); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "Give me summary of the document in the sharepoint site"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingAsyncSample.java new file mode 100644 index 000000000000..76fa908daedf --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingAsyncSample.java @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.ai.agents.persistent.models.streaming.StreamMessageUpdate; +import com.azure.ai.agents.persistent.models.streaming.StreamThreadRunCreation; +import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printStreamUpdate; + +public final class AgentStreamingAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + String agentName = "streaming_async_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful assistant. When I ask about my favorite city, answer that it is Seattle, WA. " + + "When I ask about the weather in Seattle, tell me it's currently 70 degrees and partly cloudy."); + + // Create a fully reactive chain + agentsAsyncClient.createAgent(createAgentOptions) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread() + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What's the weather like in my favorite city?") + .flatMap(message -> { + System.out.println("Created initial message"); + + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + System.out.println("----- Run started! -----"); + + return runsAsyncClient.createRunStreaming(createRunOptions) + .map(su -> handleStreamingRun(su)); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } + + private static Mono handleStreamingRun(Flux streamingUpdates) { + return streamingUpdates + .flatMap(streamUpdate -> { + if (streamUpdate.getKind() == PersistentAgentStreamEvent.THREAD_RUN_CREATED) { + System.out.println("----- Run created! -----"); + } else if (streamUpdate instanceof StreamMessageUpdate) { + StreamMessageUpdate messageUpdate = (StreamMessageUpdate) streamUpdate; + printStreamUpdate(messageUpdate); + } else if (streamUpdate.getKind() == PersistentAgentStreamEvent.THREAD_RUN_COMPLETED) { + StreamThreadRunCreation runCreation = (StreamThreadRunCreation) streamUpdate; + System.out.println("Run completed with status: " + runCreation.getMessage().getStatus()); + } + return Mono.empty(); + }) + .then(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java new file mode 100644 index 000000000000..8a162d8fbf4b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CodeInterpreterToolDefinition; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.streaming.StreamMessageUpdate; +import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import reactor.core.publisher.Flux; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printStreamUpdate; + +public final class AgentStreamingSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + + String agentName = "agent_streaming_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You politely help with math questions. Use the code interpreter tool when asked to visualize numbers.") + .setTools(Arrays.asList(new CodeInterpreterToolDefinition())); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "Hi, Assistant! Draw a graph for a line with a slope of 4 and y-intercept of 9."); + + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + + try { + Flux streamingUpdates = runsClient.createRunStreaming(createRunOptions); + + streamingUpdates.doOnNext( + streamUpdate -> { + if (streamUpdate.getKind() == PersistentAgentStreamEvent.THREAD_RUN_CREATED) { + System.out.println("----- Run started! -----"); + } else if (streamUpdate instanceof StreamMessageUpdate) { + StreamMessageUpdate messageUpdate = (StreamMessageUpdate) streamUpdate; + printStreamUpdate(messageUpdate); + } + } + ).blockLast(); + + System.out.println(); + } catch (Exception ex) { + throw ex; + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchEnterpriseFileSearchAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchEnterpriseFileSearchAsyncSample.java new file mode 100644 index 000000000000..d7f91801e5e9 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchEnterpriseFileSearchAsyncSample.java @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FileSearchToolDefinition; +import com.azure.ai.agents.persistent.models.FileSearchToolResource; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.ai.agents.persistent.models.VectorStoreConfiguration; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.ai.agents.persistent.models.VectorStoreDataSourceAssetType; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public class AgentVectorStoreBatchEnterpriseFileSearchAsyncSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + VectorStoresAsyncClient vectorStoresAsyncClient = clientBuilder.buildVectorStoresAsyncClient(); + VectorStoreFileBatchesAsyncClient vectorStoreFileBatchesAsyncClient = clientBuilder.buildVectorStoreFileBatchesAsyncClient(); + + String dataUri = Configuration.getGlobalConfiguration().get("DATA_URI", ""); + VectorStoreDataSource vectorStoreDataSource = new VectorStoreDataSource( + "assistant-6FP6sNAo21Z7pVR2ouGoPp", VectorStoreDataSourceAssetType.ID_ASSET); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create vector store + vectorStoresAsyncClient.createVectorStore( + null, "sample_vector_store_async", + new VectorStoreConfiguration(Arrays.asList(vectorStoreDataSource)), + null, null, null) + .flatMap(vs -> { + // Create vector store file batch + return vectorStoreFileBatchesAsyncClient.createVectorStoreFileBatch( + vs.getId(), null, Arrays.asList(vectorStoreDataSource), null) + .map(batch -> { + // Return vector store ID for creating the agent + return vs.getId(); + }); + }) + .flatMap(vectorStoreId -> { + // Create agent with file search tool + FileSearchToolResource fileSearchToolResource = new FileSearchToolResource() + .setVectorStoreIds(Arrays.asList(vectorStoreId)); + + String agentName = "vector_store_batch_enterprise_file_search_async_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(new FileSearchToolDefinition())) + .setToolResources(new ToolResources().setFileSearch(fileSearchToolResource)); + + return agentsAsyncClient.createAgent(createAgentOptions); + }) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread(); + }) + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + // Create initial message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What feature does Smart Eyewear offer?" + ).flatMap(message -> { + System.out.println("Created initial message"); + + // Create and start the run + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agentId.get()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchEnterpriseFileSearchSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchEnterpriseFileSearchSample.java new file mode 100644 index 000000000000..494907732784 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchEnterpriseFileSearchSample.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FileSearchToolDefinition; +import com.azure.ai.agents.persistent.models.FileSearchToolResource; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreConfiguration; +import com.azure.ai.agents.persistent.models.VectorStoreDataSource; +import com.azure.ai.agents.persistent.models.VectorStoreDataSourceAssetType; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public class AgentVectorStoreBatchEnterpriseFileSearchSample { + + public static void main(String[] args) { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + VectorStoresClient vectorStoresClient = clientBuilder.buildVectorStoresClient(); + VectorStoreFileBatchesClient vectorStoreFileBatchesClient = clientBuilder.buildVectorStoreFileBatchesClient(); + + String dataUri = Configuration.getGlobalConfiguration().get("DATA_URI", ""); + VectorStoreDataSource vectorStoreDataSource = new VectorStoreDataSource( + "assistant-6FP6sNAo21Z7pVR2ouGoPp", VectorStoreDataSourceAssetType.ID_ASSET); + + VectorStore vs = vectorStoresClient.createVectorStore( + null, "sample_vector_store", + new VectorStoreConfiguration(Arrays.asList(vectorStoreDataSource)), + null, null, null + ); + + vectorStoreFileBatchesClient.createVectorStoreFileBatch(vs.getId(), + null, Arrays.asList(vectorStoreDataSource), null); + + FileSearchToolResource fileSearchToolResource = new FileSearchToolResource() + .setVectorStoreIds(Arrays.asList(vs.getId())); + + String agentName = "vector_store_batch_enterprise_file_search_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(new FileSearchToolDefinition())) + .setToolResources(new ToolResources().setFileSearch(fileSearchToolResource)); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What feature does Smart Eyewear offer?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchFileSearchAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchFileSearchAsyncSample.java new file mode 100644 index 000000000000..34af0d672a3b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchFileSearchAsyncSample.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.FileSearchToolDefinition; +import com.azure.ai.agents.persistent.models.FileSearchToolResource; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.io.File; +import java.io.FileNotFoundException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; + +public class AgentVectorStoreBatchFileSearchAsyncSample { + + public static void main(String[] args) throws FileNotFoundException, URISyntaxException { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + + PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); + ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + FilesAsyncClient filesAsyncClient = clientBuilder.buildFilesAsyncClient(); + VectorStoresAsyncClient vectorStoresAsyncClient = clientBuilder.buildVectorStoresAsyncClient(); + VectorStoreFileBatchesAsyncClient vectorStoreFileBatchesAsyncClient = clientBuilder.buildVectorStoreFileBatchesAsyncClient(); + + Path productFile = getFile("product_info.md"); + + // Track resources for cleanup + AtomicReference agentId = new AtomicReference<>(); + AtomicReference threadId = new AtomicReference<>(); + + // Create vector store + vectorStoresAsyncClient.createVectorStore( + null, "my_vector_store_async", + null, null, null, null) + .flatMap(vectorStore -> { + // Upload file for agent + return filesAsyncClient.uploadFile(new UploadFileRequest( + new FileDetails( + BinaryData.fromFile(productFile)) + .setFilename("sample_product_info.md"), + FilePurpose.AGENTS)) + .flatMap(uploadedFile -> { + // Create vector store file batch + return vectorStoreFileBatchesAsyncClient.createVectorStoreFileBatch( + vectorStore.getId(), Arrays.asList(uploadedFile.getId()), null, null) + .map(batch -> { + // Return vector store for creating agent + return vectorStore; + }); + }); + }) + .flatMap(vectorStore -> { + // Create agent with file search tool + FileSearchToolResource fileSearchToolResource = new FileSearchToolResource() + .setVectorStoreIds(Arrays.asList(vectorStore.getId())); + + String agentName = "vector_store_batch_file_search_async_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(new FileSearchToolDefinition())) + .setToolResources(new ToolResources().setFileSearch(fileSearchToolResource)); + + return agentsAsyncClient.createAgent(createAgentOptions); + }) + .flatMap(agent -> { + System.out.println("Created agent: " + agent.getId()); + agentId.set(agent.getId()); + + return threadsAsyncClient.createThread(); + }) + .flatMap(thread -> { + System.out.println("Created thread: " + thread.getId()); + threadId.set(thread.getId()); + + // Create initial message + return messagesAsyncClient.createMessage( + thread.getId(), + MessageRole.USER, + "What feature does Smart Eyewear offer?" + ).flatMap(message -> { + System.out.println("Created initial message"); + + // Create and start the run + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agentId.get()) + .setAdditionalInstructions(""); + + return runsAsyncClient.createRun(createRunOptions) + .flatMap(threadRun -> { + System.out.println("Created run, waiting for completion..."); + return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); + }) + .flatMap(completedRun -> { + System.out.println("Run completed with status: " + completedRun.getStatus()); + return printRunMessagesAsync(messagesAsyncClient, thread.getId()); + }); + }); + }) + .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) + .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) + .block(); // Only block at the end of the reactive chain + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentVectorStoreBatchFileSearchAsyncSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found"); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchFileSearchSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchFileSearchSample.java new file mode 100644 index 000000000000..0863e3ffe115 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentVectorStoreBatchFileSearchSample.java @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.FileSearchToolDefinition; +import com.azure.ai.agents.persistent.models.FileSearchToolResource; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreFileBatch; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.io.File; +import java.io.FileNotFoundException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; +import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; + +public class AgentVectorStoreBatchFileSearchSample { + + public static void main(String[] args) throws FileNotFoundException, URISyntaxException { + PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .credential(new DefaultAzureCredentialBuilder().build()); + PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); + ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); + MessagesClient messagesClient = clientBuilder.buildMessagesClient(); + RunsClient runsClient = clientBuilder.buildRunsClient(); + FilesClient filesClient = clientBuilder.buildFilesClient(); + VectorStoresClient vectorStoresClient = clientBuilder.buildVectorStoresClient(); + VectorStoreFileBatchesClient vectorStoreFileBatchesClient = clientBuilder.buildVectorStoreFileBatchesClient(); + + Path productFile = getFile("product_info.md"); + + VectorStore vectorStore = vectorStoresClient.createVectorStore( + null, "my_vector_store", + null, null, null, null); + + FileInfo uploadedAgentFile = filesClient.uploadFile(new UploadFileRequest( + new FileDetails( + BinaryData.fromFile(productFile)) + .setFilename("sample_product_info.md"), + FilePurpose.AGENTS)); + + VectorStoreFileBatch vectorStoreFileBatch = vectorStoreFileBatchesClient.createVectorStoreFileBatch( + vectorStore.getId(), Arrays.asList(uploadedAgentFile.getId()), null, null); + + FileSearchToolResource fileSearchToolResource = new FileSearchToolResource() + .setVectorStoreIds(Arrays.asList(vectorStore.getId())); + + String agentName = "vector_store_batch_file_search_example"; + CreateAgentOptions createAgentOptions = new CreateAgentOptions("gpt-4o-mini") + .setName(agentName) + .setInstructions("You are a helpful agent") + .setTools(Arrays.asList(new FileSearchToolDefinition())) + .setToolResources(new ToolResources().setFileSearch(fileSearchToolResource)); + PersistentAgent agent = agentsClient.createAgent(createAgentOptions); + + PersistentAgentThread thread = threadsClient.createThread(); + ThreadMessage createdMessage = messagesClient.createMessage( + thread.getId(), + MessageRole.USER, + "What feature does Smart Eyewear offer?"); + + try { + //run agent + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) + .setAdditionalInstructions(""); + ThreadRun threadRun = runsClient.createRun(createRunOptions); + + waitForRunCompletion(thread.getId(), threadRun, runsClient); + printRunMessages(messagesClient, thread.getId()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } finally { + //cleanup + threadsClient.deleteThread(thread.getId()); + agentsClient.deleteAgent(agent.getId()); + } + } + + private static Path getFile(String fileName) throws FileNotFoundException, URISyntaxException { + URL resource = AgentVectorStoreBatchFileSearchSample.class.getClassLoader().getResource(fileName); + if (resource == null) { + throw new FileNotFoundException("File not found"); + } + File file = new File(resource.toURI()); + return file.toPath(); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/ReadmeSamples.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/ReadmeSamples.java new file mode 100644 index 000000000000..920a59bc174d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/ReadmeSamples.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.agents.persistent; + +public final class ReadmeSamples { + public void readmeSamples() { + // BEGIN: com.azure.ai.agents.persistent.readme + // END: com.azure.ai.agents.persistent.readme + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java new file mode 100644 index 000000000000..860627282055 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.MessageContent; +import com.azure.ai.agents.persistent.models.MessageDeltaImageFileContent; +import com.azure.ai.agents.persistent.models.MessageDeltaTextContent; +import com.azure.ai.agents.persistent.models.MessageImageFileContent; +import com.azure.ai.agents.persistent.models.MessageTextContent; +import com.azure.ai.agents.persistent.models.RunStatus; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.streaming.StreamMessageUpdate; +import com.azure.core.http.rest.PagedIterable; +import org.jetbrains.annotations.NotNull; +import reactor.core.publisher.Mono; +import java.util.concurrent.atomic.AtomicReference; + +public class SampleUtils { + + public static void printRunMessages(MessagesClient messagesClient, String threadId) { + + // BEGIN: com.azure.ai.agents.persistent.SampleUtils.printRunMessages + + PagedIterable runMessages = messagesClient.listMessages(threadId); + for (ThreadMessage message : runMessages) { + System.out.print(String.format("%1$s - %2$s : ", message.getCreatedAt(), message.getRole())); + for (MessageContent contentItem : message.getContent()) { + if (contentItem instanceof MessageTextContent) { + System.out.print((((MessageTextContent) contentItem).getText().getValue())); + } else if (contentItem instanceof MessageImageFileContent) { + String imageFileId = (((MessageImageFileContent) contentItem).getImageFile().getFileId()); + System.out.print("Image from ID: " + imageFileId); + } + System.out.println(); + } + } + + // END: com.azure.ai.agents.persistent.SampleUtils.printRunMessages + } + + public static Mono printRunMessagesAsync(MessagesAsyncClient messagesAsyncClient, String threadId) { + // BEGIN: com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync + + return messagesAsyncClient.listMessages(threadId) + .doOnNext(message -> { + System.out.print(String.format("%1$s - %2$s : ", message.getCreatedAt(), message.getRole())); + message.getContent().forEach(contentItem -> { + if (contentItem instanceof MessageTextContent) { + System.out.print((((MessageTextContent) contentItem).getText().getValue())); + } else if (contentItem instanceof MessageImageFileContent) { + String imageFileId = (((MessageImageFileContent) contentItem).getImageFile().getFileId()); + System.out.print("Image from ID: " + imageFileId); + } + System.out.println(); + }); + }) + .then(); + + // END: com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync + } + + + public static void printStreamUpdate(StreamMessageUpdate messageUpdate) { + + // BEGIN: com.azure.ai.agents.persistent.SampleUtils.printStreamUpdate + + messageUpdate.getMessage().getDelta().getContent().stream().forEach(delta -> { + if (delta instanceof MessageDeltaImageFileContent) { + MessageDeltaImageFileContent imgContent = (MessageDeltaImageFileContent) delta; + System.out.println("Image fileId: " + imgContent.getImageFile().getFileId()); + } else if (delta instanceof MessageDeltaTextContent) { + MessageDeltaTextContent textContent = (MessageDeltaTextContent) delta; + System.out.print(textContent.getText().getValue()); + } + }); + + // END: com.azure.ai.agents.persistent.SampleUtils.printStreamUpdate + } + + public static Mono printStreamUpdateAsync(StreamMessageUpdate messageUpdate) { + // BEGIN: com.azure.ai.agents.persistent.SampleUtils.printStreamUpdateAsync + + return Mono.fromRunnable(() -> { + messageUpdate.getMessage().getDelta().getContent().stream().forEach(delta -> { + if (delta instanceof MessageDeltaImageFileContent) { + MessageDeltaImageFileContent imgContent = (MessageDeltaImageFileContent) delta; + System.out.println("Image fileId: " + imgContent.getImageFile().getFileId()); + } else if (delta instanceof MessageDeltaTextContent) { + MessageDeltaTextContent textContent = (MessageDeltaTextContent) delta; + System.out.print(textContent.getText().getValue()); + } + }); + }); + + // END: com.azure.ai.agents.persistent.SampleUtils.printStreamUpdateAsync + } + + public static void waitForRunCompletion(String threadId, ThreadRun threadRun, RunsClient runsClient) + throws InterruptedException { + + // BEGIN: com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion + + do { + Thread.sleep(500); + threadRun = runsClient.getRun(threadId, threadRun.getId()); + } + while ( + threadRun.getStatus() == RunStatus.QUEUED + || threadRun.getStatus() == RunStatus.IN_PROGRESS + || threadRun.getStatus() == RunStatus.REQUIRES_ACTION); + + if (threadRun.getStatus() == RunStatus.FAILED) { + System.out.println(threadRun.getLastError().getMessage()); + } + + // END: com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion + } + + public static Mono waitForRunCompletionAsync(String threadId, ThreadRun threadRun, RunsAsyncClient runsAsyncClient) { + // BEGIN: com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync + + return Mono.defer(() -> runsAsyncClient.getRun(threadId, threadRun.getId())) + .flatMap(run -> { + if (run.getStatus() == RunStatus.QUEUED + || run.getStatus() == RunStatus.IN_PROGRESS + || run.getStatus() == RunStatus.REQUIRES_ACTION) { + return Mono.delay(java.time.Duration.ofMillis(500)) + .then(waitForRunCompletionAsync(threadId, run, runsAsyncClient)); + } else { + if (run.getStatus() == RunStatus.FAILED && run.getLastError() != null) { + System.out.println(run.getLastError().getMessage()); + } + return Mono.just(run); + } + }); + + // END: com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync + } + + @NotNull + public static void cleanUpResources(AtomicReference threadId, ThreadsAsyncClient threadsAsyncClient, AtomicReference agentId, PersistentAgentsAdministrationAsyncClient agentsAsyncClient) { + // Always clean up resources regardless of success or failure + System.out.println("Cleaning up resources..."); + + // Clean up thread if created + if (threadId.get() != null) { + threadsAsyncClient.deleteThread(threadId.get()) + .doOnSuccess(ignored -> System.out.println("Thread deleted: " + threadId.get())) + .doOnError(error -> System.err.println("Failed to delete thread: " + error.getMessage())) + .subscribe(); + } + + // Clean up agent if created + if (agentId.get() != null) { + agentsAsyncClient.deleteAgent(agentId.get()) + .doOnSuccess(ignored -> System.out.println("Agent deleted: " + agentId.get())) + .doOnError(error -> System.err.println("Failed to delete agent: " + error.getMessage())) + .subscribe(); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/resources/product_info.md b/sdk/ai/azure-ai-agents-persistent/src/samples/resources/product_info.md new file mode 100644 index 000000000000..041155831d53 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/resources/product_info.md @@ -0,0 +1,51 @@ +# Information about product item_number: 1 + +## Brand +Contoso Galaxy Innovations + +## Category +Smart Eyewear + +## Features +- Augmented Reality interface +- Voice-controlled AI assistant +- HD video recording with 3D audio +- UV protection and blue light filtering +- Wireless charging with extended battery life + +## User Guide + +### 1. Introduction +Introduction to your new SmartView Glasses + +### 2. Product Overview +Overview of features and controls + +### 3. Sizing and Fit +Finding your perfect fit and style adjustments + +### 4. Proper Care and Maintenance +Cleaning and caring for your SmartView Glasses + +### 5. Break-in Period +Adjusting to the augmented reality experience + +### 6. Safety Tips +Safety guidelines for public and private spaces + +### 7. Troubleshooting +Quick fixes for common issues + +## Warranty Information +Two-year limited warranty on all electronic components + +## Contact Information +Customer Support at support@contoso-galaxy-innovations.com + +## Return Policy +30-day return policy with no questions asked + +## FAQ +- How to sync your SmartView Glasses with your devices +- Troubleshooting connection issues +- Customizing your augmented reality environment diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/resources/sample.html b/sdk/ai/azure-ai-agents-persistent/src/samples/resources/sample.html new file mode 100644 index 000000000000..a94253429cdb --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/resources/sample.html @@ -0,0 +1,12 @@ + + + + + + Sample Document + + +

This is a sample document about Java

+

Java is an object oriented language

+ + diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/resources/sample_image.jpg b/sdk/ai/azure-ai-agents-persistent/src/samples/resources/sample_image.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6fa0cd7149de7fde8cb9cd10e8daf8467211c550 GIT binary patch literal 3347 zcmbW0dpMNc-pB7T#yCXAIj3^UsZz`&kwH-i4+@clXVRD?O2%nyDdbEU!Xt$cW)fqB z$Z29aNKQG8Q<|Kb8Nw|wd+cXldtcZ4*ZaQTwSL$7-uL>g`}%#>S~vF#cM=e{v9h)T zAP@+U&T9a73UIf?W3K>!ogJV90DvF>gF*lp&p~)$1BL!;-0^^;_}_l#!4U!Q^M=3Q zOZ?aGZUa>HK9xfz`HxKY5U=k`v%mpMJz2T}sQu;9& zPXyI0s#~RGNI%@r^ zhPL*OPTJe9Zu;lG{(-@vFT*2K(=%UZzcIhh&2yGley*;qgB!ngxF7)ZZ>;~2{SPh# zkBg6Y2K?|HE(l*JFQ5p1n930W33ErdcaWs2evF`$MaGlrRv|S5C$_XtaIdh8I&w;b zvxD|8vi}{}o&Oivf586BH3ID7T}(a%6ak=tt=~@*wV;zdqs(n#Od06fnVS}C0>4$~ zHB1^@|MmPbeYw2-En-`|RL6rQAtngOfX$md zIUuKe0`D>Hnt&X)%lAJjyE5t-h&IekJ-@;Q_yn5T9XWM!zqvqFbYZ0I)V3FK65B4s zKWhETJ)nEfwnjIQ`uxmC zbN+3Oj%Ees1*N@}KGP*)q(f_~4Gv6P*yDgUhCZ7SkrR#iBfoqwbT;KwQBS~zd$8T8 z$I;@!?&18?OH?iZgHX5fz6FT1uMIYo-meqL|7d;ZjsEOO*uI){bD9|t+hYShU*8td z=0voGua6Wr_M#NdN9Gx)96y5CGuLn;jSHl?!Z|Cnb!AgdTvgS@Yy*F))A%vpze>JT zL%;ZyL@say7H2oea|8i)i&{zSJ;f`^s4GKFUrDUN@oXHyZ$(+5lb|wvVE&nY>i%10 zD`-DKL#e`o{6R3!ovJ%OURjwPv>6^5!7g30B&Q{W!}1H1I46GHbSuykfF^4C z?nir0f4nQ;;yH25=iRbP>GZcS1@D8kGR9$V6d(Moik1X3Stt9aUsu=X4lWOxACNqC zgLBM?pMZ`b7q|GK|IsV}ejjn|e7E4y0*rxHD~pWdYziYoXU&td+s|s$nW7D#xg-l#$dL;40g{}Q(_EE1cEvM7YK2HYE6kYt$ipEnSi>8tqL;C-^ z=2!o!#ZUh><`Q3pJXGy>5b%yYc3&@a6C4bv}YBJ~V zk#O@=vzOg=x3E`t03~GhrbIqrZ%<}st;R26*dBj?9FDPVZ&g(>v5WrFiw+ru)vHBF zehTV4VGXS(Yo^RiVW)I$Wibv}D_#@|`hI=d0os8Xv6sc$)k`XiOD$;qS!z*#c+Vj=k<+G-%}K3qmu&kl2H{E*>$xwaoFT;ELJ>jgfF^2HYSEGNj$ zO><^(fT{*PEco6riT#tK4rOD{gXZBSg!SpYal@_&O-9afU}~_Ne?FO*|H?gIy;R7E z99D0mV-v?%h?>}*Ld z@^qg9`bXzshu^m=@Ub1A@uO=#Y)rAUoBV){Yc*A7&!|-pXPf%UbtstQ6ve122ZD`Q@ZHO~Yc@iMJProDq9*)~GNG^f zcVEr4zLr&IJIL&du4X0?5ZEE&?Z*fc$;yegi}02{ic4}?568l6?1W8MvF{V|7vA+L zG6Ta(e(TpZfH+)9`_v{|(e|oPm|M{O3oUrhaB-$usWgb4wA=N>UiYW*wh&?_>f{+P zrULx4i}lQFZYkVXJwvg&LF=+H#xrJhBML?co$(Xf!oi*QS~Lx5Hcc`$1sW(a^qr&ds@N?+3KbsxIgD_Se78vtD0}UZSwmnUoo6!x4kE*G8(EVq(J*uCOE5x8bn78gK2Ol0{a0E_ zi0*A_l#dFwRF^b#`1-Ep=!W-Y@Xh2fe);bN@#xmWCI~jmDUs#c(7-{yP^>ht+E=GJ zkS=rZ=XmUx{4aY3!`MwiD?=?2C72K^TzCV37D{h06Ph)>SI#0|> { + assertNotNull(createdAgent, "Persistent agent should not be null"); + agent = createdAgent; + assertAgent(createdAgent); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateAgent(HttpClient httpClient) { + setup(httpClient); + createTestAgent(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListAgents(HttpClient httpClient) { + setup(httpClient); + createTestAgent(); + + // Validate agent listing + StepVerifier.create(agentsAsyncClient.listAgents().take(10).collectList()).assertNext(agents -> { + assertNotNull(agents, "Agent list should not be null"); + assertTrue(agents != null, "Agent list should not be empty"); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetAgent(HttpClient httpClient) { + setup(httpClient); + createTestAgent(); + + StepVerifier.create(agentsAsyncClient.getAgent(agent.getId())).assertNext(retrievedAgent -> { + assertAgent(retrievedAgent); + assertTrue(retrievedAgent.getId().equals(agent.getId()), + "Retrieved agent ID should match created agent ID"); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testUpdateAgent(HttpClient httpClient) { + setup(httpClient); + createTestAgent(); + + UpdateAgentOptions updateOptions + = new UpdateAgentOptions(agent.getId()).setInstructions("Updated instructions for the agent"); + + StepVerifier.create(agentsAsyncClient.updateAgent(updateOptions)).assertNext(updatedAgent -> { + assertAgent(updatedAgent); + assertTrue(updatedAgent.getInstructions().equals("Updated instructions for the agent"), + "Updated agent instructions should match"); + assertTrue(updatedAgent.getId().equals(agent.getId()), "Updated agent ID should match created agent ID"); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testDeleteAgent(HttpClient httpClient) { + setup(httpClient); + createTestAgent(); + + StepVerifier.create(agentsAsyncClient.deleteAgent(agent.getId())).assertNext(deletionStatus -> { + assertNotNull(deletionStatus, "Deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Agent should be deleted"); + agent = null; + }).verifyComplete(); + } + + @AfterEach + public void cleanup() { + if (agent != null) { + agentsAsyncClient.deleteAgent(agent.getId()).block(); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/AdministrationClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/AdministrationClientTest.java new file mode 100644 index 000000000000..98e340edf183 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/AdministrationClientTest.java @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.AgentDeletionStatus; +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.UpdateAgentOptions; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static com.azure.ai.agents.persistent.TestUtils.size; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class AdministrationClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private PersistentAgentsAdministrationClient agentsClient; + private PersistentAgent agent; + + private PersistentAgent createAgent(String agentName) { + CreateAgentOptions options + = new CreateAgentOptions("gpt-4o-mini").setName(agentName).setInstructions("You are a helpful agent"); + PersistentAgent createdAgent = agentsClient.createAgent(options); + assertNotNull(createdAgent, "Persistent agent should not be null"); + return createdAgent; + } + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + agentsClient = clientBuilder.buildClient(); + agent = createAgent("TestAgent"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateAgent(HttpClient httpClient) { + setup(httpClient); + assertAgent(agent); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListAgents(HttpClient httpClient) { + setup(httpClient); + + // Validate the agent listing + PagedIterable agents = agentsClient.listAgents(); + + assertNotNull(agents, "Agent list should not be null"); + assertTrue(size(agents) > 0, "Agent list should not be empty"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetAgent(HttpClient httpClient) { + setup(httpClient); + + PersistentAgent retrievedAgent = agentsClient.getAgent(agent.getId()); + assertAgent(retrievedAgent); + assertTrue(retrievedAgent.getId().equals(agent.getId()), "Retrieved agent ID should match created agent ID"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testUpdateAgent(HttpClient httpClient) { + setup(httpClient); + + UpdateAgentOptions updateOptions + = new UpdateAgentOptions(agent.getId()).setInstructions("Updated instructions for the agent"); + PersistentAgent updatedAgent = agentsClient.updateAgent(updateOptions); + assertAgent(updatedAgent); + assertTrue(updatedAgent.getInstructions().equals("Updated instructions for the agent"), + "Updated agent instructions should match"); + assertTrue(updatedAgent.getId().equals(agent.getId()), "Updated agent ID should match created agent ID"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testDeleteAgent(HttpClient httpClient) { + setup(httpClient); + + AgentDeletionStatus deletionStatus = agentsClient.deleteAgent(agent.getId()); + assertNotNull(deletionStatus, "Deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Agent should be deleted"); + agent = null; + } + + @AfterEach + public void cleanup() { + if (agent != null) { + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java new file mode 100644 index 000000000000..cf92bf4b0f17 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.RunStatus; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.test.TestMode; +import com.azure.core.test.TestProxyTestBase; +import com.azure.core.test.models.CustomMatcher; +import com.azure.core.test.models.TestProxySanitizer; +import com.azure.core.test.models.TestProxySanitizerType; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import reactor.core.publisher.Mono; +import java.util.ArrayList; +import java.util.Arrays; + +import static com.azure.ai.agents.persistent.TestUtils.FAKE_API_KEY; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + +public class ClientTestBase extends TestProxyTestBase { + + private boolean sanitizersRemoved = false; + + protected PersistentAgentsAdministrationClientBuilder getClientBuilder(HttpClient httpClient) { + + PersistentAgentsAdministrationClientBuilder builder = new PersistentAgentsAdministrationClientBuilder() + .httpClient(interceptorManager.isPlaybackMode() ? interceptorManager.getPlaybackClient() : httpClient); + TestMode testMode = getTestMode(); + if (testMode != TestMode.LIVE) { + addCustomMatchers(); + addTestRecordCustomSanitizers(); + // Disable "$..id"=AZSDK3430, "Set-Cookie"=AZSDK2015 for both azure and non-azure clients from the list of common sanitizers. + if (!sanitizersRemoved) { + interceptorManager.removeSanitizers("AZSDK3430", "AZSDK3493", "AZSDK2015"); + sanitizersRemoved = true; + } + } + + if (testMode == TestMode.PLAYBACK) { + builder.endpoint("https://localhost:8080").credential(new AzureKeyCredential(FAKE_API_KEY)); + } else if (testMode == TestMode.RECORD) { + builder.addPolicy(interceptorManager.getRecordPolicy()) + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .credential(new DefaultAzureCredentialBuilder().build()); + } else { + builder.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .credential(new DefaultAzureCredentialBuilder().build()); + } + + String serviceVersion = Configuration.getGlobalConfiguration().get("SERVICE_VERSION"); + if (serviceVersion != null) { + builder.serviceVersion(AgentsServiceVersion.valueOf(serviceVersion)); + } + return builder; + } + + private void addTestRecordCustomSanitizers() { + + ArrayList sanitizers = new ArrayList<>(); + sanitizers.add(new TestProxySanitizer("$..key", null, "REDACTED", TestProxySanitizerType.BODY_KEY)); + sanitizers.add(new TestProxySanitizer("$..endpoint", "https://.+?/api/projects/.+?/", "https://REDACTED/", + TestProxySanitizerType.URL)); + sanitizers.add(new TestProxySanitizer("Content-Type", + "(^multipart\\/form-data; boundary=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{2})", + "multipart\\/form-data; boundary=BOUNDARY", TestProxySanitizerType.HEADER)); + + interceptorManager.addSanitizers(sanitizers); + + } + + private void addCustomMatchers() { + interceptorManager.addMatchers(new CustomMatcher().setExcludedHeaders(Arrays.asList("Cookie", "Set-Cookie"))); + } + + protected void assertAgent(PersistentAgent agent) { + assertNotNull(agent, "Agent should not be null"); + assertNotNull(agent.getId(), "Agent ID should not be null"); + assertNotNull(agent.getName(), "Agent name should not be null"); + } + + protected void waitForRunCompletion(ThreadRun threadRun, RunsClient runsClient) { + int retryLeft = 50; + do { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + fail("Thread sleep interrupted " + e.getMessage()); + } + threadRun = runsClient.getRun(threadRun.getThreadId(), threadRun.getId()); + } while ((--retryLeft > 0) + && ((threadRun.getStatus() == RunStatus.QUEUED) + || (threadRun.getStatus() == RunStatus.IN_PROGRESS) + || (threadRun.getStatus() == RunStatus.REQUIRES_ACTION))); + + if (threadRun.getStatus() == RunStatus.FAILED || retryLeft == 0) { + fail("Run failed or couldn't complete in time"); + } + } + + public static Mono waitForRunCompletionAsync(ThreadRun threadRun, RunsAsyncClient runsAsyncClient) { + return Mono.defer(() -> runsAsyncClient.getRun(threadRun.getThreadId(), threadRun.getId())).flatMap(run -> { + if (run.getStatus() == RunStatus.QUEUED + || run.getStatus() == RunStatus.IN_PROGRESS + || run.getStatus() == RunStatus.REQUIRES_ACTION) { + return Mono.delay(java.time.Duration.ofMillis(500)) + .then(waitForRunCompletionAsync(run, runsAsyncClient)); + } else { + if (run.getStatus() == RunStatus.FAILED && run.getLastError() != null) { + System.out.println(run.getLastError().getMessage()); + } + return Mono.just(run); + } + }); + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/FilesAsyncClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/FilesAsyncClientTest.java new file mode 100644 index 000000000000..c09d14406b04 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/FilesAsyncClientTest.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.core.http.HttpClient; +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; +import java.util.ArrayList; +import java.util.List; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class FilesAsyncClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private FilesAsyncClient filesAsyncClient; + private List uploadedFiles; + private static final String SAMPLE_TEXT = "Sample text for testing upload"; + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + filesAsyncClient = clientBuilder.buildFilesAsyncClient(); + uploadedFiles = new ArrayList<>(); + } + + private Mono uploadFile(String fileName, FilePurpose filePurpose) { + FileDetails fileDetails = new FileDetails(BinaryData.fromString(SAMPLE_TEXT)).setFilename(fileName); + UploadFileRequest uploadFileRequest = new UploadFileRequest(fileDetails, filePurpose); + + return filesAsyncClient.uploadFile(uploadFileRequest).map(uploadedFile -> { + uploadedFiles.add(uploadedFile); + assertNotNull(uploadedFile, "Uploaded file should not be null"); + return uploadedFile; + }); + } + + private Mono uploadFile(String fileName) { + return uploadFile(fileName, FilePurpose.AGENTS); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testUploadFile(HttpClient httpClient) { + setup(httpClient); + + // upload new file + String fileName = "upload_file_test.txt"; + StepVerifier.create(uploadFile(fileName)).assertNext(uploadedFile -> { + assertNotNull(uploadedFile, "Uploaded file should not be null"); + assertEquals(fileName, uploadedFile.getFilename(), "File name should match"); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetFile(HttpClient httpClient) { + setup(httpClient); + + // upload new file + String fileName = "get_file_test.txt"; + StepVerifier.create(uploadFile(fileName).flatMap(uploadedFile -> { + String fileId = uploadedFile.getId(); + return filesAsyncClient.getFile(fileId); + })).assertNext(fileInfo -> { + assertNotNull(fileInfo, "FileInfo should not be null"); + assertEquals(fileName, fileInfo.getFilename(), "Retrieved file name should match"); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testDeleteFile(HttpClient httpClient) { + setup(httpClient); + + // upload new file + String fileName = "delete_file_test.txt"; + StepVerifier.create(uploadFile(fileName).flatMap(uploadedFile -> { + String fileId = uploadedFile.getId(); + return filesAsyncClient.deleteFile(fileId); + })).assertNext(deletionStatus -> { + assertNotNull(deletionStatus, "Deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "File should be marked as deleted"); + }).verifyComplete(); + + // Remove the file from our tracking list since it's been deleted + uploadedFiles.clear(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListFiles(HttpClient httpClient) { + setup(httpClient); + + // upload new file + String fileName = "list_files_test.txt"; + StepVerifier.create(uploadFile(fileName).then(filesAsyncClient.listFiles())).assertNext(listResponse -> { + assertNotNull(listResponse, "File list response should not be null"); + List fileInfos = listResponse.getData(); + assertNotNull(fileInfos, "File list should not be null"); + assertTrue(fileInfos.size() > 0, "File list should not be empty"); + }).verifyComplete(); + } + + @AfterEach + public void cleanup() { + for (FileInfo fileInfo : uploadedFiles) { + try { + filesAsyncClient.deleteFile(fileInfo.getId()).block(); + } catch (Exception e) { + System.out.println("Failed to clean up file: " + fileInfo.getFilename()); + System.out.println(e.getMessage()); + } + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/FilesClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/FilesClientTest.java new file mode 100644 index 000000000000..3c6b8c89884d --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/FilesClientTest.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.FileDeletionStatus; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FileListResponse; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.core.http.HttpClient; +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import java.util.ArrayList; +import java.util.List; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class FilesClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private FilesClient filesClient; + private List uploadedFiles; + private static final String SAMPLE_TEXT = "Sample text for testing upload"; + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + filesClient = clientBuilder.buildFilesClient(); + uploadedFiles = new ArrayList<>(); + } + + private FileInfo uploadFile(String fileName) { + FileDetails fileDetails = new FileDetails(BinaryData.fromString(SAMPLE_TEXT)).setFilename(fileName); + UploadFileRequest uploadFileRequest = new UploadFileRequest(fileDetails, FilePurpose.AGENTS); + FileInfo uploadedFile = filesClient.uploadFile(uploadFileRequest); + assertNotNull(uploadedFile, "Uploaded file should not be null"); + uploadedFiles.add(uploadedFile); + return uploadedFile; + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testUploadFile(HttpClient httpClient) { + setup(httpClient); + + // upload new file + String fileName = "upload_file_test.txt"; + FileInfo uploadedFile = uploadFile(fileName); + + assertEquals(fileName, uploadedFile.getFilename(), "File name should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetFile(HttpClient httpClient) { + setup(httpClient); + + // upload new file + String fileName = "get_file_test.txt"; + FileInfo uploadedFile = uploadFile(fileName); + + // Retrieve file information + FileInfo fileInfo = filesClient.getFile(uploadedFile.getId()); + assertNotNull(fileInfo, "FileInfo should not be null"); + assertEquals(fileName, fileInfo.getFilename(), "Retrieved file name should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testDeleteFile(HttpClient httpClient) { + setup(httpClient); + + // upload new file + String fileName = "delete_file_test.txt"; + FileInfo uploadedFile = uploadFile(fileName); + + // Delete the created file + FileDeletionStatus deletionStatus = filesClient.deleteFile(uploadedFile.getId()); + assertTrue(deletionStatus.isDeleted(), "File should be marked as deleted"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListFiles(HttpClient httpClient) { + setup(httpClient); + + // upload new file + String fileName = "list_files_test.txt"; + FileInfo uploadedFile = uploadFile(fileName); + + FileListResponse listResponse = filesClient.listFiles(); + assertNotNull(listResponse, "File list response should not be null"); + List fileInfos = listResponse.getData(); + assertNotNull(fileInfos, "File list should not be null"); + assertTrue(fileInfos.size() > 0, "File list should not be empty"); + } + + @AfterEach + public void cleanup() { + for (FileInfo fileInfo : uploadedFiles) { + try { + FileDeletionStatus deletionStatus = filesClient.deleteFile(fileInfo.getId()); + } catch (Exception e) { + System.out.println("Failed to clean up file: " + fileInfo.getFilename()); + System.out.println(e.getMessage()); + } + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesAsyncClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesAsyncClientTest.java new file mode 100644 index 000000000000..c1da16f58a7b --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesAsyncClientTest.java @@ -0,0 +1,191 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.core.http.HttpClient; +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import reactor.test.StepVerifier; +import java.time.Duration; +import java.util.HashMap; +import java.util.Map; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class MessagesAsyncClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private PersistentAgentsAdministrationAsyncClient agentsAsyncClient; + private ThreadsAsyncClient threadsAsyncClient; + private MessagesAsyncClient messagesAsyncClient; + private PersistentAgent agent; + private PersistentAgentThread thread; + + private void createTestAgent(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + agentsAsyncClient = clientBuilder.buildAsyncClient(); + threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); + + CreateAgentOptions options + = new CreateAgentOptions("gpt-4o-mini").setName("TestAgent").setInstructions("You are a helpful agent"); + + StepVerifier.create(agentsAsyncClient.createAgent(options)).assertNext(createdAgent -> { + assertNotNull(createdAgent, "Persistent agent should not be null"); + agent = createdAgent; + }).verifyComplete(); + + StepVerifier.create(threadsAsyncClient.createThread()).assertNext(createdThread -> { + assertNotNull(createdThread, "Thread should not be null"); + thread = createdThread; + }).verifyComplete(); + } + + @Disabled + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateAndRetrieveMessage(HttpClient httpClient) { + createTestAgent(httpClient); + + // Test content + BinaryData content = BinaryData.fromString("What do you know about Microsoft"); + + // Create a message and verify + StepVerifier.create(messagesAsyncClient.createMessage(thread.getId(), MessageRole.USER, content)) + .assertNext(createdMessage -> { + assertNotNull(createdMessage, "Created message should not be null"); + assertNotNull(createdMessage.getId(), "Message ID should not be null"); + assertEquals(MessageRole.USER, createdMessage.getRole(), "Message role should be USER"); + + // Verify by retrieving the message + StepVerifier.create(messagesAsyncClient.getMessage(thread.getId(), createdMessage.getId())) + .assertNext(retrievedMessage -> { + assertNotNull(retrievedMessage, "Retrieved message should not be null"); + assertEquals(createdMessage.getId(), retrievedMessage.getId(), "Message IDs should match"); + }) + .verifyComplete(); + }) + .verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateMessageWithMetadata(HttpClient httpClient) { + createTestAgent(httpClient); + + // Create a message with metadata + Map metadata = new HashMap<>(); + metadata.put("priority", "high"); + + BinaryData content = BinaryData.fromString("This is a message with metadata"); + + StepVerifier + .create(messagesAsyncClient.createMessage(thread.getId(), MessageRole.USER, content, null, metadata)) + .assertNext(messageWithMetadata -> { + assertNotNull(messageWithMetadata, "Message with metadata should not be null"); + assertNotNull(messageWithMetadata.getMetadata(), "Message metadata should not be null"); + assertEquals("high", messageWithMetadata.getMetadata().get("priority"), + "Metadata priority should match"); + }) + .verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testUpdateMessage(HttpClient httpClient) { + createTestAgent(httpClient); + + // Create initial message + BinaryData content = BinaryData.fromString("Initial message"); + ThreadMessage[] messageRef = new ThreadMessage[1]; + + StepVerifier.create(messagesAsyncClient.createMessage(thread.getId(), MessageRole.USER, content)) + .assertNext(createdMessage -> { + messageRef[0] = createdMessage; + assertNotNull(createdMessage, "Created message should not be null"); + }) + .verifyComplete(); + + // Update message metadata + Map updatedMetadata = new HashMap<>(); + updatedMetadata.put("updated", "true"); + updatedMetadata.put("timestamp", String.valueOf(System.currentTimeMillis())); + + StepVerifier.create(messagesAsyncClient.updateMessage(thread.getId(), messageRef[0].getId(), updatedMetadata)) + .assertNext(updatedMessage -> { + assertNotNull(updatedMessage, "Updated message should not be null"); + assertNotNull(updatedMessage.getMetadata(), "Updated metadata should not be null"); + assertEquals("true", updatedMessage.getMetadata().get("updated"), + "Metadata updated flag should be true"); + }) + .verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListMessagesDefault(HttpClient httpClient) { + createTestAgent(httpClient); + + // Create at least two messages + BinaryData content1 = BinaryData.fromString("Message 1"); + BinaryData content2 = BinaryData.fromString("Message 2"); + + StepVerifier.create(messagesAsyncClient.createMessage(thread.getId(), MessageRole.USER, content1)) + .assertNext(message -> assertNotNull(message, "First message should not be null")) + .verifyComplete(); + + StepVerifier.create(messagesAsyncClient.createMessage(thread.getId(), MessageRole.USER, content2)) + .assertNext(message -> assertNotNull(message, "Second message should not be null")) + .verifyComplete(); + + // List messages and verify + StepVerifier.create(messagesAsyncClient.listMessages(thread.getId()).collectList()).assertNext(messagesList -> { + assertNotNull(messagesList, "Messages list should not be null"); + assertTrue(messagesList.size() >= 2, "There should be at least 2 messages"); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListMessagesWithParameters(HttpClient httpClient) { + createTestAgent(httpClient); + + // Create multiple messages + for (int i = 0; i < 5; i++) { + BinaryData content = BinaryData.fromString("Message " + i); + + StepVerifier.create(messagesAsyncClient.createMessage(thread.getId(), MessageRole.USER, content)) + .assertNext(message -> assertNotNull(message, "Created message should not be null")) + .verifyComplete(); + } + + // List with parameters and verify + StepVerifier.create(messagesAsyncClient.listMessages(thread.getId(), null, 10, null, null, null).collectList()) + .assertNext(filteredMessages -> { + assertNotNull(filteredMessages, "Filtered messages should not be null"); + assertTrue(filteredMessages.size() <= 10, "Messages list should have at most 10 messages"); + }) + .verifyComplete(); + } + + @AfterEach + public void cleanup() { + if (thread != null && threadsAsyncClient != null) { + threadsAsyncClient.deleteThread(thread.getId()).block(Duration.ofSeconds(30)); + } + if (agent != null && agentsAsyncClient != null) { + agentsAsyncClient.deleteAgent(agent.getId()).block(Duration.ofSeconds(30)); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesClientTest.java new file mode 100644 index 000000000000..d36c496fc977 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesClientTest.java @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.MessageRole; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadDeletionStatus; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import java.util.HashMap; +import java.util.Map; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class MessagesClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private PersistentAgentsAdministrationClient agentsClient; + private ThreadsClient threadsClient; + private MessagesClient messagesClient; + private PersistentAgent agent; + private PersistentAgentThread thread; + + private PersistentAgent createAgent(String agentName) { + CreateAgentOptions options + = new CreateAgentOptions("gpt-4o-mini").setName(agentName).setInstructions("You are a helpful agent"); + PersistentAgent createdAgent = agentsClient.createAgent(options); + assertNotNull(createdAgent, "Persistent agent should not be null"); + return createdAgent; + } + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + agentsClient = clientBuilder.buildClient(); + threadsClient = clientBuilder.buildThreadsClient(); + messagesClient = clientBuilder.buildMessagesClient(); + agent = createAgent("TestAgent"); + thread = threadsClient.createThread(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateAndRetrieveMessage(HttpClient httpClient) { + setup(httpClient); + // Create message + ThreadMessage createdMessage + = messagesClient.createMessage(thread.getId(), MessageRole.USER, "What do you know about Microsoft"); + assertNotNull(createdMessage, "Created message should not be null"); + assertNotNull(createdMessage.getId(), "Message ID should not be null"); + assertEquals(MessageRole.USER, createdMessage.getRole(), "Message role should be USER"); + // Retrieve message + ThreadMessage retrievedMessage = messagesClient.getMessage(thread.getId(), createdMessage.getId()); + assertNotNull(retrievedMessage, "Retrieved message should not be null"); + assertEquals(createdMessage.getId(), retrievedMessage.getId(), "Message IDs should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateMessageWithMetadata(HttpClient httpClient) { + setup(httpClient); + Map metadata = new HashMap<>(); + metadata.put("priority", "high"); + ThreadMessage messageWithMetadata = messagesClient.createMessage(thread.getId(), MessageRole.USER, + "This is a message with metadata", null, metadata); + assertNotNull(messageWithMetadata, "Message with metadata should not be null"); + assertNotNull(messageWithMetadata.getMetadata(), "Message metadata should not be null"); + assertEquals("high", messageWithMetadata.getMetadata().get("priority"), "Metadata priority should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testUpdateMessage(HttpClient httpClient) { + setup(httpClient); + // Create initial message + ThreadMessage createdMessage + = messagesClient.createMessage(thread.getId(), MessageRole.USER, "Initial message"); + // Update message metadata + Map updatedMetadata = new HashMap<>(); + updatedMetadata.put("updated", "true"); + updatedMetadata.put("timestamp", String.valueOf(System.currentTimeMillis())); + ThreadMessage updatedMessage + = messagesClient.updateMessage(thread.getId(), createdMessage.getId(), updatedMetadata); + assertNotNull(updatedMessage, "Updated message should not be null"); + assertNotNull(updatedMessage.getMetadata(), "Updated metadata should not be null"); + assertEquals("true", updatedMessage.getMetadata().get("updated"), "Metadata updated flag should be true"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListMessagesDefault(HttpClient httpClient) { + setup(httpClient); + // Create at least two messages + messagesClient.createMessage(thread.getId(), MessageRole.USER, "Message 1"); + messagesClient.createMessage(thread.getId(), MessageRole.USER, "Message 2"); + PagedIterable messagesList = messagesClient.listMessages(thread.getId()); + + assertNotNull(messagesList, "Messages list should not be null"); + assertTrue(messagesList.stream().count() >= 2, "There should be at least 2 messages"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListMessagesWithParameters(HttpClient httpClient) { + setup(httpClient); + // Create multiple messages + for (int i = 0; i < 3; i++) { + messagesClient.createMessage(thread.getId(), MessageRole.USER, "Message " + i); + } + PagedIterable filteredMessages = messagesClient.listMessages(thread.getId(), null, // runId + 10, // limit + null, // order + null, // after + null); // before + + assertNotNull(filteredMessages, "Filtered messages should not be null"); + assertTrue(filteredMessages.stream().count() <= 10, "Messages list should have at most 10 messages"); + } + + @AfterEach + public void cleanup() { + if (thread != null) { + ThreadDeletionStatus deletionStatus = threadsClient.deleteThread(thread.getId()); + assertNotNull(deletionStatus, "Deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Thread should be deleted"); + } + if (agent != null) { + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunStepsAsyncClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunStepsAsyncClientTest.java new file mode 100644 index 000000000000..902404354bcb --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunStepsAsyncClientTest.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.http.HttpClient; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import reactor.test.StepVerifier; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class RunStepsAsyncClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private PersistentAgentsAdministrationAsyncClient agentsAsyncClient; + private ThreadsAsyncClient threadsAsyncClient; + private RunsAsyncClient runsAsyncClient; + private RunStepsAsyncClient runStepsAsyncClient; + private PersistentAgent agent; + private PersistentAgentThread thread; + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + agentsAsyncClient = clientBuilder.buildAsyncClient(); + threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + runStepsAsyncClient = clientBuilder.buildRunStepsAsyncClient(); + } + + private void createTestAgent() { + CreateAgentOptions options + = new CreateAgentOptions("gpt-4o-mini").setName("TestAgent").setInstructions("You are a helpful agent"); + + StepVerifier.create(agentsAsyncClient.createAgent(options)).assertNext(createdAgent -> { + assertNotNull(createdAgent, "Persistent agent should not be null"); + agent = createdAgent; + assertAgent(createdAgent); + }).verifyComplete(); + } + + private void createTestThread() { + StepVerifier.create(threadsAsyncClient.createThread()).assertNext(createdThread -> { + assertNotNull(createdThread, "Created thread should not be null"); + thread = createdThread; + }).verifyComplete(); + } + + private ThreadRun createAndWaitForRun() { + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()); + + ThreadRun[] run = new ThreadRun[1]; + + StepVerifier.create(runsAsyncClient.createRun(createRunOptions)).assertNext(createdRun -> { + assertNotNull(createdRun, "Created run should not be null"); + run[0] = createdRun; + }).verifyComplete(); + + // Wait for run completion + waitForRunCompletionAsync(run[0], runsAsyncClient); + + return run[0]; + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListRunSteps(HttpClient httpClient) { + setup(httpClient); + createTestAgent(); + createTestThread(); + + ThreadRun run = createAndWaitForRun(); + + StepVerifier.create(runStepsAsyncClient.listRunSteps(run.getThreadId(), run.getId()).take(10).collectList()) + .assertNext(runSteps -> { + assertNotNull(runSteps, "Run steps list should not be null"); + assertTrue(runSteps.size() > 0, "Run steps list should contain at least one step"); + }) + .verifyComplete(); + } + + @Disabled + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetRunStep(HttpClient httpClient) { + setup(httpClient); + createTestAgent(); + createTestThread(); + + ThreadRun run = createAndWaitForRun(); + + // First get a list of run steps + StepVerifier.create(runStepsAsyncClient.listRunSteps(run.getThreadId(), run.getId()).take(1).single()) + .assertNext(firstRunStep -> { + assertNotNull(firstRunStep, "First run step should not be null"); + + // Then retrieve a specific run step by ID + StepVerifier + .create(runStepsAsyncClient.getRunStep(run.getThreadId(), run.getId(), firstRunStep.getId())) + .assertNext(retrievedRunStep -> { + assertNotNull(retrievedRunStep, "Retrieved run step should not be null"); + assertEquals(firstRunStep.getId(), retrievedRunStep.getId(), "Run step IDs should match"); + }) + .verifyComplete(); + }) + .verifyComplete(); + } + + @AfterEach + public void cleanup() { + if (thread != null) { + StepVerifier.create(threadsAsyncClient.deleteThread(thread.getId())).assertNext(deletionStatus -> { + assertNotNull(deletionStatus, "Thread deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Thread should be deleted"); + }).verifyComplete(); + } + + if (agent != null) { + agentsAsyncClient.deleteAgent(agent.getId()).block(); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunStepsClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunStepsClientTest.java new file mode 100644 index 000000000000..57c39cfb9983 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunStepsClientTest.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.RunStep; +import com.azure.ai.agents.persistent.models.ThreadDeletionStatus; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static com.azure.ai.agents.persistent.TestUtils.first; +import static com.azure.ai.agents.persistent.TestUtils.size; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class RunStepsClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private PersistentAgentsAdministrationClient agentsClient; + private ThreadsClient threadsClient; + private RunsClient runsClient; + private RunStepsClient runStepsClient; + private PersistentAgent agent; + private PersistentAgentThread thread; + + private PersistentAgent createAgent(String agentName) { + // Mimics agent creation as in other tests. + CreateAgentOptions options + = new CreateAgentOptions("gpt-4o-mini").setName(agentName).setInstructions("You are a helpful agent"); + PersistentAgent createdAgent = agentsClient.createAgent(options); + assertNotNull(createdAgent, "Persistent agent should not be null"); + return createdAgent; + } + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + agentsClient = clientBuilder.buildClient(); + threadsClient = clientBuilder.buildThreadsClient(); + runsClient = clientBuilder.buildRunsClient(); + runStepsClient = clientBuilder.buildRunStepsClient(); + agent = createAgent("TestAgent"); + thread = threadsClient.createThread(); + } + + private ThreadRun createRun() { + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()); + ThreadRun createdRun = runsClient.createRun(createRunOptions); + assertNotNull(createdRun, "Created run should not be null"); + return createdRun; + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListRunSteps(HttpClient httpClient) { + setup(httpClient); + + ThreadRun run = createRun(); + waitForRunCompletion(run, runsClient); + + PagedIterable runSteps = runStepsClient.listRunSteps(run.getThreadId(), run.getId()); + assertNotNull(runSteps, "Run steps list should not be null"); + assertTrue(size(runSteps) > 0, "Run steps list should contain at least one step"); + } + + @Disabled + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetRunSteps(HttpClient httpClient) { + setup(httpClient); + + ThreadRun run = createRun(); + waitForRunCompletion(run, runsClient); + + PagedIterable runSteps = runStepsClient.listRunSteps(run.getThreadId(), run.getId()); + assertNotNull(runSteps, "Run steps response should not be null"); + assertTrue(size(runSteps) > 0, "Run steps list should contain at least one step"); + + RunStep firstRunStep = first(runSteps); + RunStep retrievedRunStep = runStepsClient.getRunStep(run.getThreadId(), run.getId(), firstRunStep.getId()); + assertNotNull(retrievedRunStep, "Retrieved run step should not be null"); + assertEquals(firstRunStep.getId(), retrievedRunStep.getId(), "Run step IDs should match"); + } + + @AfterEach + public void cleanup() { + if (thread != null) { + ThreadDeletionStatus deletionStatus = threadsClient.deleteThread(thread.getId()); + assertNotNull(deletionStatus, "Thread deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Thread should be deleted"); + } + if (agent != null) { + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsAsyncClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsAsyncClientTest.java new file mode 100644 index 000000000000..e34f214919f0 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsAsyncClientTest.java @@ -0,0 +1,196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.http.HttpClient; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; +import java.time.Duration; +import java.util.HashMap; +import java.util.Map; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class RunsAsyncClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private PersistentAgentsAdministrationAsyncClient agentsAsyncClient; + private ThreadsAsyncClient threadsAsyncClient; + private RunsAsyncClient runsAsyncClient; + private PersistentAgent agent; + private PersistentAgentThread thread; + + private void createTestAgent(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + agentsAsyncClient = clientBuilder.buildAsyncClient(); + threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + runsAsyncClient = clientBuilder.buildRunsAsyncClient(); + + CreateAgentOptions options + = new CreateAgentOptions("gpt-4o-mini").setName("TestAgent").setInstructions("You are a helpful agent"); + + StepVerifier.create(agentsAsyncClient.createAgent(options)).assertNext(createdAgent -> { + assertNotNull(createdAgent, "Persistent agent should not be null"); + agent = createdAgent; + }).verifyComplete(); + + StepVerifier.create(threadsAsyncClient.createThread()).assertNext(createdThread -> { + assertNotNull(createdThread, "Thread should not be null"); + thread = createdThread; + }).verifyComplete(); + } + + private Mono createRunAndWaitForCompletion() { + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()); + + return runsAsyncClient.createRun(createRunOptions).flatMap(run -> waitForRunCompletionAsync(run)); + } + + private Mono waitForRunCompletionAsync(ThreadRun run) { + // Poll run status until it completes or fails + return Mono.defer(() -> runsAsyncClient.getRun(thread.getId(), run.getId())).flatMap(updatedRun -> { + String status = updatedRun.getStatus().toString(); + if ("completed".equals(status) || "failed".equals(status) || "cancelled".equals(status)) { + return Mono.just(updatedRun); + } else { + return Mono.delay(Duration.ofSeconds(2)).then(waitForRunCompletionAsync(updatedRun)); + } + }); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateAndRetrieveRun(HttpClient httpClient) { + createTestAgent(httpClient); + + StepVerifier.create(createRunAndWaitForCompletion()).assertNext(run -> { + assertNotNull(run, "Created run should not be null"); + assertNotNull(run.getId(), "Run ID should not be null"); + + // Verify by retrieving the run + StepVerifier.create(runsAsyncClient.getRun(thread.getId(), run.getId())).assertNext(retrievedRun -> { + assertNotNull(retrievedRun, "Retrieved run should not be null"); + assertEquals(run.getId(), retrievedRun.getId(), "Run IDs should match"); + }).verifyComplete(); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateRunWithMetadata(HttpClient httpClient) { + createTestAgent(httpClient); + + Map metadata = new HashMap<>(); + metadata.put("priority", "high"); + + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()).setMetadata(metadata); + + StepVerifier.create(runsAsyncClient.createRun(createRunOptions)).assertNext(run -> { + assertNotNull(run, "Run with metadata should not be null"); + assertNotNull(run.getMetadata(), "Run metadata should not be null"); + assertEquals("high", run.getMetadata().get("priority"), "Metadata priority should match"); + }).verifyComplete(); + } + + @Disabled + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testUpdateRun(HttpClient httpClient) { + createTestAgent(httpClient); + + StepVerifier.create(createRunAndWaitForCompletion()).assertNext(run -> { + // Prepare metadata updates + Map updatedMetadata = new HashMap<>(); + updatedMetadata.put("updated", "true"); + updatedMetadata.put("timestamp", String.valueOf(System.currentTimeMillis())); + + // Update and verify + StepVerifier.create(runsAsyncClient.updateRun(thread.getId(), run.getId(), updatedMetadata)) + .assertNext(updatedRun -> { + assertNotNull(updatedRun, "Updated run should not be null"); + assertNotNull(updatedRun.getMetadata(), "Updated metadata should not be null"); + assertEquals("true", updatedRun.getMetadata().get("updated"), "Updated flag should match"); + }) + .verifyComplete(); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListRunsDefault(HttpClient httpClient) { + createTestAgent(httpClient); + + // Create multiple runs + StepVerifier.create(createRunAndWaitForCompletion()) + .assertNext(run -> assertNotNull(run, "First run should not be null")) + .verifyComplete(); + + StepVerifier.create(createRunAndWaitForCompletion()) + .assertNext(run -> assertNotNull(run, "Second run should not be null")) + .verifyComplete(); + + // List runs and verify + StepVerifier.create(runsAsyncClient.listRuns(thread.getId()).collectList()).assertNext(runsList -> { + assertNotNull(runsList, "Runs list should not be null"); + assertTrue(runsList.size() >= 2, "There should be at least 2 runs"); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListRunsWithParameters(HttpClient httpClient) { + createTestAgent(httpClient); + + // Create multiple runs (at least 3) + for (int i = 0; i < 3; i++) { + createRunAndWaitForCompletion().block(Duration.ofMinutes(2)); + } + + // List with parameters and verify + StepVerifier.create(runsAsyncClient.listRuns(thread.getId(), 5, null, null, null).collectList()) + .assertNext(filteredRuns -> { + assertNotNull(filteredRuns, "Filtered runs should not be null"); + assertTrue(filteredRuns.size() <= 5, "Run list should have at most 5 runs"); + }) + .verifyComplete(); + } + + @Disabled + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCancelRun(HttpClient httpClient) { + createTestAgent(httpClient); + + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()); + + StepVerifier.create(runsAsyncClient.createRun(createRunOptions)).assertNext(run -> { + // Attempt to cancel the run (this may not always succeed if the run completes quickly) + StepVerifier.create(runsAsyncClient.cancelRun(thread.getId(), run.getId())).assertNext(cancelledRun -> { + assertNotNull(cancelledRun, "Cancelled run should not be null"); + // Note: The run might complete before we can cancel it, so we don't assert on status + }).verifyComplete(); + }).verifyComplete(); + } + + @AfterEach + public void cleanup() { + if (thread != null && threadsAsyncClient != null) { + threadsAsyncClient.deleteThread(thread.getId()).block(Duration.ofSeconds(30)); + } + if (agent != null && agentsAsyncClient != null) { + agentsAsyncClient.deleteAgent(agent.getId()).block(Duration.ofSeconds(30)); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsClientTest.java new file mode 100644 index 000000000000..839acd237524 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsClientTest.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.CreateRunOptions; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadDeletionStatus; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import java.util.HashMap; +import java.util.Map; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static com.azure.ai.agents.persistent.TestUtils.size; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class RunsClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private PersistentAgentsAdministrationClient agentsClient; + private ThreadsClient threadsClient; + private RunsClient runsClient; + private PersistentAgent agent; + private PersistentAgentThread thread; + + private PersistentAgent createAgent(String agentName) { + // Mimics agent creation as in other tests. + CreateAgentOptions options + = new CreateAgentOptions("gpt-4o-mini").setName(agentName).setInstructions("You are a helpful agent"); + PersistentAgent createdAgent = agentsClient.createAgent(options); + assertNotNull(createdAgent, "Persistent agent should not be null"); + return createdAgent; + } + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + agentsClient = clientBuilder.buildClient(); + threadsClient = clientBuilder.buildThreadsClient(); + runsClient = clientBuilder.buildRunsClient(); + agent = createAgent("TestAgent"); + thread = threadsClient.createThread(); + } + + private ThreadRun createRun() { + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()); + ThreadRun createdRun = runsClient.createRun(createRunOptions); + assertNotNull(createdRun, "Created run should not be null"); + return createdRun; + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateAndRetrieveRun(HttpClient httpClient) { + setup(httpClient); + ThreadRun run = createRun(); + assertNotNull(run.getId(), "Run ID should not be null"); + + ThreadRun retrievedRun = runsClient.getRun(thread.getId(), run.getId()); + assertNotNull(retrievedRun, "Retrieved run should not be null"); + assertEquals(run.getId(), retrievedRun.getId(), "Run IDs should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateRunWithMetadata(HttpClient httpClient) { + setup(httpClient); + + Map metadata = new HashMap<>(); + metadata.put("priority", "high"); + + CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()).setMetadata(metadata); + ThreadRun run = runsClient.createRun(createRunOptions); + assertNotNull(run, "Run with metadata should not be null"); + assertNotNull(run.getMetadata(), "Run metadata should not be null"); + assertEquals("high", run.getMetadata().get("priority"), "Metadata priority should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testUpdateRun(HttpClient httpClient) { + setup(httpClient); + ThreadRun run = createRun(); + // ensure completed before updating + waitForRunCompletion(run, runsClient); + + // Prepare metadata updates + Map updatedMetadata = new HashMap<>(); + updatedMetadata.put("updated", "true"); + updatedMetadata.put("timestamp", String.valueOf(System.currentTimeMillis())); + + ThreadRun updatedRun = runsClient.updateRun(thread.getId(), run.getId(), updatedMetadata); + + assertNotNull(updatedRun, "Updated run should not be null"); + assertNotNull(updatedRun.getMetadata(), "Updated metadata should not be null"); + assertEquals("true", updatedRun.getMetadata().get("updated"), "Updated flag should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListRunsDefault(HttpClient httpClient) { + setup(httpClient); + // Create multiple runs + for (int i = 0; i < 2; i++) { + CreateRunOptions runOptions = new CreateRunOptions(thread.getId(), agent.getId()); + ThreadRun run = runsClient.createRun(runOptions); + waitForRunCompletion(run, runsClient); + } + + PagedIterable runsList = runsClient.listRuns(thread.getId()); + assertNotNull(runsList, "Runs list should not be null"); + assertTrue(runsList.stream().count() >= 2, "There should be at least 2 runs"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListRunsWithParameters(HttpClient httpClient) { + setup(httpClient); + // Create several runs + for (int i = 0; i < 5; i++) { + CreateRunOptions runOptions = new CreateRunOptions(thread.getId(), agent.getId()); + ThreadRun run = runsClient.createRun(runOptions); + waitForRunCompletion(run, runsClient); + } + + PagedIterable runs = runsClient.listRuns(thread.getId(), 10, // limit + null, // order + null, // after + null // before + ); + + assertNotNull(runs, "Filtered runs should not be null"); + assertTrue(size(runs) <= 5, "Run list should have at most 5 runs"); + } + + @AfterEach + public void cleanup() { + if (thread != null) { + ThreadDeletionStatus deletionStatus = threadsClient.deleteThread(thread.getId()); + assertNotNull(deletionStatus, "Thread deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Thread should be deleted"); + } + if (agent != null) { + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/TestUtils.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/TestUtils.java new file mode 100644 index 000000000000..087ea7912e13 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/TestUtils.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import org.junit.jupiter.params.provider.Arguments; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Stream; + +import static com.azure.core.test.TestBase.getHttpClients; + +public class TestUtils { + + static final String DISPLAY_NAME_WITH_ARGUMENTS = "{displayName} with [{arguments}]"; + static final String FAKE_API_KEY = "fakeKeyPlaceholder"; + + /** + * Returns a stream of arguments that includes all combinations of eligible {@link HttpClient HttpClients} + * that should be tested. + * + * @return A stream of HttpClients to test. + */ + static Stream getTestParameters() { + // when this issues is closed, the newer version of junit will have better support for + // cartesian product of arguments - https://github.com/junit-team/junit5/issues/1427 + List argumentsList = new ArrayList<>(); + getHttpClients().forEach(httpClient -> argumentsList.add(Arguments.of(httpClient))); + return argumentsList.stream(); + } + + static int size(PagedIterable pagedIterable) { + int length = 0; + if (pagedIterable != null) { + for (PagedResponse page : pagedIterable.iterableByPage()) { + length += page.getValue().size(); + } + } + return length; + } + + static T first(PagedIterable pagedIterable) { + T firstElement = null; + if (pagedIterable != null) { + Iterator iterator = pagedIterable.iterator(); + if (iterator.hasNext()) { + firstElement = iterator.next(); + } + } + return firstElement; + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ThreadsAsyncClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ThreadsAsyncClientTest.java new file mode 100644 index 000000000000..b1fbe5d38f98 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ThreadsAsyncClientTest.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadDeletionStatus; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.http.HttpClient; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import reactor.test.StepVerifier; +import java.util.HashMap; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ThreadsAsyncClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private PersistentAgentsAdministrationAsyncClient agentsAsyncClient; + private ThreadsAsyncClient threadsAsyncClient; + private PersistentAgent agent; + private PersistentAgentThread thread; + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + agentsAsyncClient = clientBuilder.buildAsyncClient(); + threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); + createAgent(); + } + + private void createAgent() { + CreateAgentOptions options + = new CreateAgentOptions("gpt-4o-mini").setName("TestAgent").setInstructions("You are a helpful agent"); + + agent = agentsAsyncClient.createAgent(options).block(); + assertNotNull(agent, "Persistent agent should not be null"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateThread(HttpClient httpClient) { + setup(httpClient); + + StepVerifier.create(threadsAsyncClient.createThread()).assertNext(createdThread -> { + assertNotNull(createdThread, "Thread should not be null"); + assertNotNull(createdThread.getId(), "Thread ID should not be null"); + thread = createdThread; + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListThreads(HttpClient httpClient) { + setup(httpClient); + + // Create a thread first + thread = threadsAsyncClient.createThread().block(); + assertNotNull(thread, "Thread should not be null"); + + StepVerifier.create(threadsAsyncClient.listThreads().take(10).collectList()).assertNext(threads -> { + assertNotNull(threads, "Thread list should not be null"); + assertTrue(!threads.isEmpty(), "Thread list should not be empty"); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetThread(HttpClient httpClient) { + setup(httpClient); + + // Create a thread first + thread = threadsAsyncClient.createThread().block(); + assertNotNull(thread, "Thread should not be null"); + + StepVerifier.create(threadsAsyncClient.getThread(thread.getId())).assertNext(retrievedThread -> { + assertNotNull(retrievedThread, "Retrieved thread should not be null"); + assertTrue(thread.getId().equals(retrievedThread.getId()), "Thread ID should match"); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testUpdateThread(HttpClient httpClient) { + setup(httpClient); + + // Create a thread first + thread = threadsAsyncClient.createThread().block(); + assertNotNull(thread, "Thread should not be null"); + + HashMap metadata = new HashMap<>(); + metadata.put("testKey", "testValue"); + + StepVerifier.create(threadsAsyncClient.updateThread(thread.getId(), new ToolResources(), metadata)) + .assertNext(updatedThread -> { + assertNotNull(updatedThread, "Updated thread should not be null"); + assertTrue("testValue".equals(updatedThread.getMetadata().get("testKey")), + "Updated metadata should match"); + }) + .verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testDeleteThread(HttpClient httpClient) { + setup(httpClient); + + // Create a thread first + thread = threadsAsyncClient.createThread().block(); + assertNotNull(thread, "Thread should not be null"); + + StepVerifier.create(threadsAsyncClient.deleteThread(thread.getId())).assertNext(deletionStatus -> { + assertNotNull(deletionStatus, "Deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Thread should be deleted"); + thread = null; // Set to null since we've deleted it + }).verifyComplete(); + } + + @AfterEach + public void cleanup() { + if (thread != null) { + try { + // Attempt to delete the thread + ThreadDeletionStatus deletionStatus = threadsAsyncClient.deleteThread(thread.getId()).block(); + } catch (Exception e) { + System.out.println("Failed to cleanup thread: " + thread.getId()); + System.out.println(e.getMessage()); + } + } + if (agent != null) { + agentsAsyncClient.deleteAgent(agent.getId()).block(); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ThreadsClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ThreadsClientTest.java new file mode 100644 index 000000000000..8d5930d8c4d7 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ThreadsClientTest.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.CreateAgentOptions; +import com.azure.ai.agents.persistent.models.PersistentAgent; +import com.azure.ai.agents.persistent.models.PersistentAgentThread; +import com.azure.ai.agents.persistent.models.ThreadDeletionStatus; +import com.azure.ai.agents.persistent.models.ToolResources; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import java.util.HashMap; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ThreadsClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private PersistentAgentsAdministrationClient agentsClient; + private ThreadsClient threadsClient; + private PersistentAgent agent; + private PersistentAgentThread thread; + + private PersistentAgent createAgent(String agentName) { + CreateAgentOptions options + = new CreateAgentOptions("gpt-4o-mini").setName(agentName).setInstructions("You are a helpful agent"); + PersistentAgent createdAgent = agentsClient.createAgent(options); + assertNotNull(createdAgent, "Persistent agent should not be null"); + return createdAgent; + } + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + agentsClient = clientBuilder.buildClient(); + threadsClient = clientBuilder.buildThreadsClient(); + agent = createAgent("TestAgent"); + thread = threadsClient.createThread(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateThread(HttpClient httpClient) { + setup(httpClient); + // Validate that thread exists + assertNotNull(thread, "Thread should not be null"); + assertNotNull(thread.getId(), "Thread ID should not be null"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListThreads(HttpClient httpClient) { + setup(httpClient); + PagedIterable threadList = threadsClient.listThreads(); + assertNotNull(threadList, "Thread list should not be null"); + assertTrue(threadList.stream().count() > 0, "Thread list should not be empty"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetThread(HttpClient httpClient) { + setup(httpClient); + PersistentAgentThread retrievedThread = threadsClient.getThread(thread.getId()); + assertNotNull(retrievedThread, "Retrieved thread should not be null"); + assertTrue(thread.getId().equals(retrievedThread.getId()), "Thread ID should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testUpdateThread(HttpClient httpClient) { + setup(httpClient); + HashMap metadata = new HashMap<>(); + metadata.put("testKey", "testValue"); + PersistentAgentThread updatedThread = threadsClient.updateThread(thread.getId(), new ToolResources(), metadata); + assertNotNull(updatedThread, "Updated thread should not be null"); + assertTrue("testValue".equals(updatedThread.getMetadata().get("testKey")), "Updated metadata should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testDeleteThread(HttpClient httpClient) { + setup(httpClient); + ThreadDeletionStatus deletionStatus = threadsClient.deleteThread(thread.getId()); + assertNotNull(deletionStatus, "Deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Thread should be deleted"); + } + + @AfterEach + public void cleanup() { + if (thread != null) { + try { + // Attempt to delete the thread + ThreadDeletionStatus deletionStatus = threadsClient.deleteThread(thread.getId()); + } catch (Exception e) { + System.out.println("Failed to cleanup thread: " + thread.getId()); + System.out.println(e.getMessage()); + } + } + if (agent != null) { + agentsClient.deleteAgent(agent.getId()); + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesAsyncClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesAsyncClientTest.java new file mode 100644 index 000000000000..c8056fd4848e --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesAsyncClientTest.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreFileBatch; +import com.azure.core.http.HttpClient; +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class VectorStoreFileBatchesAsyncClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private VectorStoresAsyncClient vectorStoresAsyncClient; + private VectorStoreFileBatchesAsyncClient vectorStoreFileBatchesAsyncClient; + private FilesAsyncClient filesAsyncClient; + private List vectorStores = new ArrayList<>(); + private List uploadedFiles = new ArrayList<>(); + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + vectorStoresAsyncClient = clientBuilder.buildVectorStoresAsyncClient(); + vectorStoreFileBatchesAsyncClient = clientBuilder.buildVectorStoreFileBatchesAsyncClient(); + filesAsyncClient = clientBuilder.buildFilesAsyncClient(); + } + + private Mono uploadFile(String fileName) { + FileDetails fileDetails + = new FileDetails(BinaryData.fromString("Sample text for testing upload")).setFilename(fileName); + UploadFileRequest uploadFileRequest = new UploadFileRequest(fileDetails, FilePurpose.AGENTS); + + return filesAsyncClient.uploadFile(uploadFileRequest).map(uploadedFile -> { + uploadedFiles.add(uploadedFile); + assertNotNull(uploadedFile, "Uploaded file should not be null"); + return uploadedFile; + }); + } + + // Helper method to create a vector store + private Mono createVectorStore(String name) { + return vectorStoresAsyncClient.createVectorStore(null, name, null, null, null, null).map(vectorStore -> { + assertNotNull(vectorStore, "Vector store should not be null"); + vectorStores.add(vectorStore); + return vectorStore; + }); + } + + private Mono createVectorStoreFileBatch(String vectorStoreId, List fileIds) { + return vectorStoreFileBatchesAsyncClient.createVectorStoreFileBatch(vectorStoreId, fileIds, null, null) + .map(fileBatch -> { + assertNotNull(fileBatch, "Vector store file batch should not be null"); + return fileBatch; + }); + } + + // Test creation of a vector store file batch + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateVectorStoreFileBatch(HttpClient httpClient) { + setup(httpClient); + + String vectorStoreName = "test_create_vector_store_file_batch_async"; + + StepVerifier.create(createVectorStore(vectorStoreName) + .flatMap(vectorStore -> uploadFile("testCreateVectorStoreFileBatchAsync.txt").flatMap(uploadedFile -> { + List fileIds = Arrays.asList(uploadedFile.getId()); + return vectorStoreFileBatchesAsyncClient.createVectorStoreFileBatch(vectorStore.getId(), fileIds, null, + null); + }))).assertNext(createdBatch -> { + assertNotNull(createdBatch.getId(), "Vector store file batch ID should not be null"); + }).verifyComplete(); + } + + // Test retrieval of a vector store file batch + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetVectorStoreFileBatch(HttpClient httpClient) { + setup(httpClient); + String vectorStoreName = "test_get_vector_store_file_batch_async"; + + AtomicReference batchIdRef = new AtomicReference<>(); + + StepVerifier.create(createVectorStore(vectorStoreName) + .flatMap(vectorStore -> uploadFile("testGetVectorStoreFileBatchAsync.txt").flatMap(uploadedFile -> { + List fileIds = Arrays.asList(uploadedFile.getId()); + return vectorStoreFileBatchesAsyncClient.createVectorStoreFileBatch(vectorStore.getId(), fileIds, null, + null); + }) + .doOnNext(batch -> batchIdRef.set(batch.getId())) + .flatMap(batch -> vectorStoreFileBatchesAsyncClient.getVectorStoreFileBatch(vectorStore.getId(), + batch.getId())))) + .assertNext(retrievedBatch -> { + assertNotNull(retrievedBatch, "Retrieved file batch should not be null"); + assertEquals(batchIdRef.get(), retrievedBatch.getId(), "File batch IDs should match"); + }) + .verifyComplete(); + } + + @Disabled + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListVectorStoreFileBatchFiles(HttpClient httpClient) { + setup(httpClient); + String vectorStoreName = "test_list_vector_store_file_batches_async"; + + StepVerifier.create(createVectorStore(vectorStoreName) + .flatMap(vectorStore -> uploadFile("testListVectorStoreFileBatchesAsync.txt").flatMap(uploadedFile -> { + List fileIds = Arrays.asList(uploadedFile.getId()); + return vectorStoreFileBatchesAsyncClient.createVectorStoreFileBatch(vectorStore.getId(), fileIds, null, + null); + }) + .flatMap(batch -> vectorStoreFileBatchesAsyncClient + .listVectorStoreFileBatchFiles(vectorStore.getId(), batch.getId()) + .take(10) + .collectList()))) + .assertNext(files -> { + assertNotNull(files, "Vector store batch files list should not be null"); + // Files might not be processed yet, so we don't assert count + }) + .verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCancelVectorStoreFileBatch(HttpClient httpClient) { + setup(httpClient); + String vectorStoreName = "test_cancel_vector_store_file_batch_async"; + + StepVerifier.create(createVectorStore(vectorStoreName) + .flatMap(vectorStore -> uploadFile("testCancelVectorStoreFileBatchAsync.txt").flatMap(uploadedFile -> { + List fileIds = Arrays.asList(uploadedFile.getId()); + return vectorStoreFileBatchesAsyncClient.createVectorStoreFileBatch(vectorStore.getId(), fileIds, null, + null); + }) + .flatMap(batch -> vectorStoreFileBatchesAsyncClient.cancelVectorStoreFileBatch(vectorStore.getId(), + batch.getId())))) + .assertNext(cancelledBatch -> { + assertNotNull(cancelledBatch, "Cancelled batch should not be null"); + }) + .verifyComplete(); + } + + @AfterEach + public void cleanup() { + // Clean up uploaded files + for (FileInfo fileInfo : uploadedFiles) { + try { + filesAsyncClient.deleteFile(fileInfo.getId()).block(); + } catch (Exception e) { + System.out.println("Failed to clean up file: " + fileInfo.getFilename()); + System.out.println(e.getMessage()); + } + } + + // Clean up vector stores + for (VectorStore vectorStore : vectorStores) { + try { + vectorStoresAsyncClient.deleteVectorStore(vectorStore.getId()).block(); + } catch (Exception e) { + System.out.println("Failed to clean up vector store: " + vectorStore.getName()); + System.out.println(e.getMessage()); + } + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesClientTest.java new file mode 100644 index 000000000000..f0352e6c062f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFileBatchesClientTest.java @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.FileDeletionStatus; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreFile; +import com.azure.ai.agents.persistent.models.VectorStoreFileBatch; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static com.azure.ai.agents.persistent.TestUtils.size; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class VectorStoreFileBatchesClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private VectorStoresClient vectorStoresClient; + private VectorStoreFileBatchesClient vectorStoreFileBatchesClient; + private List vectorStores = new ArrayList<>(); + private FilesClient filesClient; + private List uploadedFiles; + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + vectorStoresClient = clientBuilder.buildVectorStoresClient(); + vectorStoreFileBatchesClient = clientBuilder.buildVectorStoreFileBatchesClient(); + filesClient = clientBuilder.buildFilesClient(); + uploadedFiles = new ArrayList<>(); + } + + private FileInfo uploadFile(String fileName) { + FileDetails fileDetails + = new FileDetails(BinaryData.fromString("Sample text for testing upload")).setFilename(fileName); + UploadFileRequest uploadFileRequest = new UploadFileRequest(fileDetails, FilePurpose.AGENTS); + FileInfo uploadedFile = filesClient.uploadFile(uploadFileRequest); + assertNotNull(uploadedFile, "Uploaded file should not be null"); + uploadedFiles.add(uploadedFile); + return uploadedFile; + } + + // Helper method to create a vector store + private VectorStore createVectorStore(String name) { + VectorStore vectorStore = vectorStoresClient.createVectorStore(null, name, null, null, null, null); + assertNotNull(vectorStore, "Vector store should not be null"); + vectorStores.add(vectorStore); + return vectorStore; + } + + private VectorStoreFileBatch createVectorStoreFileBatch(String vectorStoreId, List fileIds) { + VectorStoreFileBatch fileBatch + = vectorStoreFileBatchesClient.createVectorStoreFileBatch(vectorStoreId, fileIds, null, null); + assertNotNull(fileBatch, "Vector store file batch should not be null"); + return fileBatch; + } + + // Test creation of a vector store file batch + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateVectorStoreFileBatch(HttpClient httpClient) { + setup(httpClient); + + String vectorStoreName = "test_create_vector_store_file_batch"; + VectorStore vectorStore = createVectorStore(vectorStoreName); + + FileInfo uploadedFile = uploadFile("testCreateVectorStoreFileBatch.txt"); + List fileIds = Arrays.asList(uploadedFile.getId()); + VectorStoreFileBatch createdBatch = createVectorStoreFileBatch(vectorStore.getId(), fileIds); + + assertNotNull(createdBatch.getId(), "Vector store file batch ID should not be null"); + } + + // Test retrieval of a vector store file batch + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetVectorStoreFileBatch(HttpClient httpClient) { + setup(httpClient); + String vectorStoreName = "test_get_vector_store_file_batch"; + VectorStore vectorStore = createVectorStore(vectorStoreName); + + FileInfo uploadedFile = uploadFile("testGetVectorStoreFileBatch.txt"); + List fileIds = Arrays.asList(uploadedFile.getId()); + VectorStoreFileBatch createdBatch = createVectorStoreFileBatch(vectorStore.getId(), fileIds); + + // Retrieve the file batch by its id. + VectorStoreFileBatch retrievedBatch + = vectorStoreFileBatchesClient.getVectorStoreFileBatch(vectorStore.getId(), createdBatch.getId()); + assertNotNull(retrievedBatch, "Retrieved file batch should not be null"); + assertEquals(createdBatch.getId(), retrievedBatch.getId(), "File batch IDs should match"); + } + + @Disabled + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListVectorStoreFileBatches(HttpClient httpClient) { + setup(httpClient); + String vectorStoreName = "test_list_vector_store_file_batches"; + VectorStore vectorStore = createVectorStore(vectorStoreName); + + // Create multiple file batches + FileInfo uploadedFile = uploadFile("testListVectorStoreFileBatches.txt"); + List fileIds = Arrays.asList(uploadedFile.getId()); + VectorStoreFileBatch createdBatch = createVectorStoreFileBatch(vectorStore.getId(), fileIds); + + // List the file batches for the vector store. + PagedIterable vectorStoreFiles + = vectorStoreFileBatchesClient.listVectorStoreFileBatchFiles(vectorStore.getId(), createdBatch.getId()); + assertNotNull(vectorStoreFiles, "Vector store batch files list response should not be null"); + + // At least the two created file batches should be present. + assertTrue(size(vectorStoreFiles) > 0, "File batch list should not be empty"); + } + + @AfterEach + public void cleanup() { + // Clean up all created vector stores. + for (VectorStore vectorStore : vectorStores) { + try { + vectorStoresClient.deleteVectorStore(vectorStore.getId()); + } catch (Exception e) { + System.out.println("Failed to clean up vector store: " + vectorStore.getName()); + System.out.println(e.getMessage()); + } + } + for (FileInfo fileInfo : uploadedFiles) { + try { + FileDeletionStatus deletionStatus = filesClient.deleteFile(fileInfo.getId()); + } catch (Exception e) { + System.out.println("Failed to clean up file: " + fileInfo.getFilename()); + System.out.println(e.getMessage()); + } + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFilesAsyncClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFilesAsyncClientTest.java new file mode 100644 index 000000000000..f3ab21fe0de8 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFilesAsyncClientTest.java @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreFile; +import com.azure.core.http.HttpClient; +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; +import java.util.ArrayList; +import java.util.List; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class VectorStoreFilesAsyncClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private VectorStoresAsyncClient vectorStoresAsyncClient; + private VectorStoreFilesAsyncClient vectorStoreFilesAsyncClient; + private FilesAsyncClient filesAsyncClient; + private List vectorStores; + private List uploadedFiles; + private List vectorStoreFiles; + private VectorStore vectorStore; + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + vectorStoresAsyncClient = clientBuilder.buildVectorStoresAsyncClient(); + vectorStoreFilesAsyncClient = clientBuilder.buildVectorStoreFilesAsyncClient(); + filesAsyncClient = clientBuilder.buildFilesAsyncClient(); + vectorStores = new ArrayList<>(); + uploadedFiles = new ArrayList<>(); + vectorStoreFiles = new ArrayList<>(); + } + + // Helper method to create a vector store. + private Mono createVectorStore(String name) { + return vectorStoresAsyncClient.createVectorStore(null, name, null, null, null, null).map(store -> { + assertNotNull(store, "Vector store should not be null"); + vectorStores.add(store); + vectorStore = store; + return store; + }); + } + + // Helper method to upload a file using FilesAsyncClient. + private Mono uploadFile(String fileName) { + FileDetails fileDetails + = new FileDetails(BinaryData.fromString("Sample text for vector store file upload")).setFilename(fileName); + UploadFileRequest uploadFileRequest = new UploadFileRequest(fileDetails, FilePurpose.AGENTS); + + return filesAsyncClient.uploadFile(uploadFileRequest).map(uploadedFile -> { + assertNotNull(uploadedFile, "Uploaded file should not be null"); + uploadedFiles.add(uploadedFile); + return uploadedFile; + }); + } + + private Mono createVectorStoreFile(String vectorStoreId, String fileId) { + return vectorStoreFilesAsyncClient.createVectorStoreFile(vectorStoreId, fileId, null, null) + .map(vectorStoreFile -> { + assertNotNull(vectorStoreFile, "Vector store file should not be null"); + vectorStoreFiles.add(vectorStoreFile); + return vectorStoreFile; + }); + } + + // Test uploading a vector store file. + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateVectorStoreFile(HttpClient httpClient) { + setup(httpClient); + + StepVerifier + .create(createVectorStore("VectorStoreFilesAsyncClientTest") + .flatMap(store -> uploadFile("create_vector_store_file_async.txt") + .flatMap(uploadedFile -> createVectorStoreFile(store.getId(), uploadedFile.getId())))) + .assertNext(vectorStoreFile -> { + assertNotNull(vectorStoreFile.getId(), "Vector store file ID should not be null"); + }) + .verifyComplete(); + } + + // Test retrieving a vector store file. + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetVectorStoreFile(HttpClient httpClient) { + setup(httpClient); + + StepVerifier + .create( + createVectorStore( + "VectorStoreFilesAsyncClientTest") + .flatMap( + store -> uploadFile("get_vector_store_file_async.txt") + .flatMap(uploadedFile -> createVectorStoreFile(store.getId(), uploadedFile.getId())) + .flatMap(vectorStoreFile -> vectorStoreFilesAsyncClient + .getVectorStoreFile(store.getId(), vectorStoreFile.getId())))) + .assertNext(retrievedFile -> { + assertNotNull(retrievedFile, "Retrieved vector store file should not be null"); + }) + .verifyComplete(); + } + + // Test listing vector store files. + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListVectorStoreFiles(HttpClient httpClient) { + setup(httpClient); + + StepVerifier + .create(createVectorStore("VectorStoreFilesAsyncClientTest") + .flatMap(store -> uploadFile("list_vector_store_file1_async.txt") + .flatMap(uploadedFile1 -> createVectorStoreFile(store.getId(), uploadedFile1.getId())) + .then(uploadFile("list_vector_store_file2_async.txt")) + .flatMap(uploadedFile2 -> createVectorStoreFile(store.getId(), uploadedFile2.getId())) + .then(vectorStoreFilesAsyncClient.listVectorStoreFiles(store.getId()).take(10).collectList()))) + .assertNext(files -> { + assertNotNull(files, "Vector store files list should not be null"); + assertTrue(!files.isEmpty(), "There should be at least one vector store file"); + }) + .verifyComplete(); + } + + // Test deleting a vector store file. + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testDeleteVectorStoreFile(HttpClient httpClient) { + setup(httpClient); + + StepVerifier + .create( + createVectorStore( + "VectorStoreFilesAsyncClientTest") + .flatMap( + store -> uploadFile("delete_vector_store_file_async.txt") + .flatMap(uploadedFile -> createVectorStoreFile(store.getId(), uploadedFile.getId())) + .flatMap(vectorStoreFile -> vectorStoreFilesAsyncClient + .deleteVectorStoreFile(store.getId(), vectorStoreFile.getId())))) + .assertNext(deletionStatus -> { + assertNotNull(deletionStatus, "Deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Vector store file should be marked as deleted"); + }) + .verifyComplete(); + } + + @AfterEach + public void cleanup() { + // Clean up all created vector stores + for (VectorStore vectorStore : vectorStores) { + try { + vectorStoresAsyncClient.deleteVectorStore(vectorStore.getId()).block(); + } catch (Exception e) { + System.out.println("Failed to clean up vector store: " + vectorStore.getName()); + System.out.println(e.getMessage()); + } + } + // Clean up all uploaded files. + for (FileInfo fileInfo : uploadedFiles) { + try { + filesAsyncClient.deleteFile(fileInfo.getId()).block(); + } catch (Exception e) { + System.out.println("Failed to clean up file: " + fileInfo.getFilename()); + System.out.println(e.getMessage()); + } + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFilesClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFilesClientTest.java new file mode 100644 index 000000000000..984968adc86f --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoreFilesClientTest.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.implementation.models.FileDetails; +import com.azure.ai.agents.persistent.implementation.models.UploadFileRequest; +import com.azure.ai.agents.persistent.models.FileDeletionStatus; +import com.azure.ai.agents.persistent.models.FileInfo; +import com.azure.ai.agents.persistent.models.FilePurpose; +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreFile; +import com.azure.ai.agents.persistent.models.VectorStoreFileDeletionStatus; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import java.util.ArrayList; +import java.util.List; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static com.azure.ai.agents.persistent.TestUtils.size; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class VectorStoreFilesClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private VectorStoresClient vectorStoresClient; + private VectorStoreFilesClient vectorStoreFilesClient; + private FilesClient filesClient; + private List vectorStores; + private List uploadedFiles; + private List vectorStoreFiles; + private VectorStore vectorStore; + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + vectorStoresClient = clientBuilder.buildVectorStoresClient(); + vectorStoreFilesClient = clientBuilder.buildVectorStoreFilesClient(); + filesClient = clientBuilder.buildFilesClient(); + vectorStores = new ArrayList<>(); + uploadedFiles = new ArrayList<>(); + vectorStoreFiles = new ArrayList<>(); + vectorStore = createVectorStore("VectorStoreFilesClientTest"); + } + + // Helper method to create a vector store. + private VectorStore createVectorStore(String name) { + VectorStore vectorStore = vectorStoresClient.createVectorStore(null, name, null, null, null, null); + assertNotNull(vectorStore, "Vector store should not be null"); + vectorStores.add(vectorStore); + return vectorStore; + } + + // Helper method to upload a file using FilesClient. + private FileInfo uploadFile(String fileName) { + FileDetails fileDetails + = new FileDetails(BinaryData.fromString("Sample text for vector store file upload")).setFilename(fileName); + UploadFileRequest uploadFileRequest = new UploadFileRequest(fileDetails, FilePurpose.AGENTS); + FileInfo uploadedFile = filesClient.uploadFile(uploadFileRequest); + assertNotNull(uploadedFile, "Uploaded file should not be null"); + uploadedFiles.add(uploadedFile); + return uploadedFile; + } + + private VectorStoreFile createVectorStoreFile(String vectorStoreId, String fileId) { + VectorStoreFile vectorStoreFile + = vectorStoreFilesClient.createVectorStoreFile(vectorStoreId, fileId, null, null); + assertNotNull(vectorStoreFile, "Vector store file should not be null"); + + vectorStoreFiles.add(vectorStoreFile); + return vectorStoreFile; + } + + // Test uploading a vector store file. + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateVectorStoreFile(HttpClient httpClient) { + setup(httpClient); + + FileInfo uploadedFile = uploadFile("create_vector_store_file.txt"); + VectorStoreFile vectorStoreFile = createVectorStoreFile(vectorStore.getId(), uploadedFile.getId()); + + assertNotNull(vectorStoreFile.getId(), "Vector store file ID should not be null"); + } + + // Test retrieving a vector store file. + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetVectorStoreFile(HttpClient httpClient) { + setup(httpClient); + + FileInfo uploadedFile = uploadFile("get_vector_store_file.txt"); + VectorStoreFile vectorStoreFile = createVectorStoreFile(vectorStore.getId(), uploadedFile.getId()); + + VectorStoreFile retrievedFile + = vectorStoreFilesClient.getVectorStoreFile(vectorStore.getId(), vectorStoreFile.getId()); + assertNotNull(retrievedFile, "Retrieved vector store file should not be null"); + assertEquals(vectorStoreFile.getId(), retrievedFile.getId(), "Vector store file IDs should match"); + } + + // Test listing vector store files. + @Disabled + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListVectorStoreFiles(HttpClient httpClient) { + setup(httpClient); + + FileInfo uploadedFile1 = uploadFile("list_vector_store_file1.txt"); + FileInfo uploadedFile2 = uploadFile("list_vector_store_file2.txt"); + + // Upload two files. + createVectorStoreFile(vectorStore.getId(), uploadedFile1.getId()); + createVectorStoreFile(vectorStore.getId(), uploadedFile2.getId()); + + PagedIterable vectorStoreFiles + = vectorStoreFilesClient.listVectorStoreFiles(vectorStore.getId()); + + assertNotNull(vectorStoreFiles, "Vector store files list should not be null"); + assertTrue(size(vectorStoreFiles) > 0, "There should be at least one vector store file"); + } + + // Test deleting a vector store file. + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testDeleteVectorStoreFile(HttpClient httpClient) { + setup(httpClient); + + FileInfo uploadedFile = uploadFile("delete_vector_store_file.txt"); + VectorStoreFile vectorStoreFile = createVectorStoreFile(vectorStore.getId(), uploadedFile.getId()); + + VectorStoreFileDeletionStatus deletionStatus + = vectorStoreFilesClient.deleteVectorStoreFile(vectorStore.getId(), vectorStoreFile.getId()); + assertNotNull(deletionStatus, "Deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Vector store file should be marked as deleted"); + } + + @AfterEach + public void cleanup() { + // Clean up all created vector stores + for (VectorStore vectorStore : vectorStores) { + try { + vectorStoresClient.deleteVectorStore(vectorStore.getId()); + } catch (Exception e) { + System.out.println("Failed to clean up vector store: " + vectorStore.getName()); + System.out.println(e.getMessage()); + } + } + // Clean up all uploaded files. + for (FileInfo fileInfo : uploadedFiles) { + try { + FileDeletionStatus deletionStatus = filesClient.deleteFile(fileInfo.getId()); + } catch (Exception e) { + System.out.println("Failed to clean up file: " + fileInfo.getFilename()); + System.out.println(e.getMessage()); + } + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoresAsyncClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoresAsyncClientTest.java new file mode 100644 index 000000000000..39b7b7acfafd --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoresAsyncClientTest.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.core.http.HttpClient; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class VectorStoresAsyncClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private VectorStoresAsyncClient vectorStoresAsyncClient; + private List vectorStores; + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + vectorStoresAsyncClient = clientBuilder.buildVectorStoresAsyncClient(); + vectorStores = new ArrayList<>(); + } + + private Mono createVectorStore(String vectorStoreName) { + return vectorStoresAsyncClient.createVectorStore(null, vectorStoreName, null, null, null, null) + .map(vectorStore -> { + assertNotNull(vectorStore, "Vector store should not be null"); + assertNotNull(vectorStore.getId(), "Vector store ID should not be null"); + assertEquals(vectorStoreName, vectorStore.getName(), "Vector store name should match"); + vectorStores.add(vectorStore); + return vectorStore; + }); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateVectorStore(HttpClient httpClient) { + setup(httpClient); + String vectorStoreName = "test_create_vector_store_async"; + + StepVerifier.create(createVectorStore(vectorStoreName)).assertNext(vectorStore -> { + assertNotNull(vectorStore, "Vector store should not be null"); + assertEquals(vectorStoreName, vectorStore.getName(), "Vector store name should match"); + }).verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetVectorStore(HttpClient httpClient) { + setup(httpClient); + String vectorStoreName = "test_get_vector_store_async"; + + StepVerifier + .create(createVectorStore(vectorStoreName) + .flatMap(createdStore -> vectorStoresAsyncClient.getVectorStore(createdStore.getId()))) + .assertNext(retrievedVectorStore -> { + assertNotNull(retrievedVectorStore, "Retrieved vector store should not be null"); + assertEquals(vectorStoreName, retrievedVectorStore.getName(), "Vector store names should match"); + }) + .verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testModifyVectorStore(HttpClient httpClient) { + setup(httpClient); + String vectorStoreName = "test_modify_vector_store_async"; + String updatedName = vectorStoreName + "_updated"; + Map metadata = new HashMap<>(); + metadata.put("environment", "test"); + + StepVerifier + .create(createVectorStore(vectorStoreName).flatMap(createdStore -> vectorStoresAsyncClient + .modifyVectorStore(createdStore.getId(), updatedName, null, metadata))) + .assertNext(modifiedVectorStore -> { + assertNotNull(modifiedVectorStore, "Modified vector store should not be null"); + assertEquals(updatedName, modifiedVectorStore.getName(), "Vector store name should be updated"); + assertNotNull(modifiedVectorStore.getMetadata(), "Vector store metadata should not be null"); + assertEquals("test", modifiedVectorStore.getMetadata().get("environment"), + "Metadata environment value should match"); + }) + .verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListVectorStores(HttpClient httpClient) { + setup(httpClient); + String vectorStoreName = "test_list_vector_store_async"; + + StepVerifier + .create(createVectorStore(vectorStoreName) + .then(Mono.defer(() -> vectorStoresAsyncClient.listVectorStores().take(10).collectList()))) + .assertNext(vectorStoreList -> { + assertNotNull(vectorStoreList, "Vector store list should not be null"); + assertTrue(vectorStoreList.size() > 0, "Vector store list should not be empty"); + }) + .verifyComplete(); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testDeleteVectorStore(HttpClient httpClient) { + setup(httpClient); + String vectorStoreName = "test_delete_vector_store_async"; + + StepVerifier.create(createVectorStore(vectorStoreName).flatMap(createdStore -> { + return vectorStoresAsyncClient.deleteVectorStore(createdStore.getId()).doOnNext(status -> { + // Remove from cleanup list since it's already deleted + vectorStores.remove(createdStore); + }); + })).assertNext(deletionStatus -> { + assertNotNull(deletionStatus, "Deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Vector store should be marked as deleted"); + }).verifyComplete(); + } + + @AfterEach + public void cleanup() { + for (VectorStore vectorStore : new ArrayList<>(vectorStores)) { + try { + vectorStoresAsyncClient.deleteVectorStore(vectorStore.getId()).block(); + vectorStores.remove(vectorStore); + } catch (Exception e) { + System.out.println("Failed to clean up vector store: " + vectorStore.getName()); + System.out.println(e.getMessage()); + } + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoresClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoresClientTest.java new file mode 100644 index 000000000000..d3d4a3973f01 --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/VectorStoresClientTest.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.ai.agents.persistent; + +import com.azure.ai.agents.persistent.models.VectorStore; +import com.azure.ai.agents.persistent.models.VectorStoreDeletionStatus; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.azure.ai.agents.persistent.TestUtils.DISPLAY_NAME_WITH_ARGUMENTS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class VectorStoresClientTest extends ClientTestBase { + + private PersistentAgentsAdministrationClientBuilder clientBuilder; + private VectorStoresClient vectorStoresClient; + private List vectorStores; + + private void setup(HttpClient httpClient) { + clientBuilder = getClientBuilder(httpClient); + vectorStoresClient = clientBuilder.buildVectorStoresClient(); + vectorStores = new ArrayList<>(); + } + + private VectorStore createVectorStore(String vectorStoreName) { + VectorStore vectorStore = vectorStoresClient.createVectorStore(null, vectorStoreName, null, null, null, null); + assertNotNull(vectorStore, "Vector store should not be null"); + vectorStores.add(vectorStore); + return vectorStore; + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testCreateVectorStore(HttpClient httpClient) { + setup(httpClient); + + String vectorStoreName = "test_create_vector_store"; + VectorStore vectorStore = createVectorStore(vectorStoreName); + + assertNotNull(vectorStore.getId(), "Vector store ID should not be null"); + assertEquals(vectorStoreName, vectorStore.getName(), "Vector store name should match"); + vectorStores.add(vectorStore); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testGetVectorStore(HttpClient httpClient) { + setup(httpClient); + + String vectorStoreName = "test_get_vector_store"; + VectorStore vectorStore = createVectorStore(vectorStoreName); + VectorStore retrievedVectorStore = vectorStoresClient.getVectorStore(vectorStore.getId()); + + assertNotNull(retrievedVectorStore, "Retrieved vector store should not be null"); + assertEquals(vectorStore.getId(), retrievedVectorStore.getId(), "Vector store IDs should match"); + assertEquals(vectorStore.getName(), retrievedVectorStore.getName(), "Vector store names should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testModifyVectorStore(HttpClient httpClient) { + setup(httpClient); + + String vectorStoreName = "test_modify_vector_store"; + VectorStore vectorStore = createVectorStore(vectorStoreName); + + // update vector store with a new name and metadata + String updatedName = vectorStoreName + "_updated"; + Map metadata = new HashMap<>(); + metadata.put("environment", "test"); + + VectorStore modifiedVectorStore = vectorStoresClient.modifyVectorStore(vectorStore.getId(), updatedName, null, // not modifying expiration policy + metadata); + + assertNotNull(modifiedVectorStore, "Modified vector store should not be null"); + assertEquals(updatedName, modifiedVectorStore.getName(), "Vector store name should be updated"); + assertNotNull(modifiedVectorStore.getMetadata(), "Vector store metadata should not be null"); + assertEquals("test", modifiedVectorStore.getMetadata().get("environment"), + "Metadata environment value should match"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testListVectorStores(HttpClient httpClient) { + setup(httpClient); + + String vectorStoreName = "test_list_vector_store"; + VectorStore vectorStore = createVectorStore(vectorStoreName); + + // Retrieve the list of vector stores + PagedIterable vectorStoreList = vectorStoresClient.listVectorStores(); + assertNotNull(vectorStoreList, "Vector store list should not be null"); + assertTrue(vectorStoreList.stream().count() > 0, "Vector store list should not be empty"); + } + + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") + public void testDeleteVectorStore(HttpClient httpClient) { + setup(httpClient); + + String vectorStoreName = "test_delete_vector_store"; + VectorStore vectorStore = createVectorStore(vectorStoreName); + + VectorStoreDeletionStatus deletionStatus = vectorStoresClient.deleteVectorStore(vectorStore.getId()); + assertNotNull(deletionStatus, "Deletion status should not be null"); + assertTrue(deletionStatus.isDeleted(), "Vector store should be marked as deleted"); + } + + @AfterEach + public void cleanup() { + for (VectorStore vectorStore : vectorStores) { + try { + VectorStoreDeletionStatus deletionStatus = vectorStoresClient.deleteVectorStore(vectorStore.getId()); + } catch (Exception e) { + System.out.println("Failed to clean up vector store: " + vectorStore.getName()); + System.out.println(e.getMessage()); + } + } + } +} diff --git a/sdk/ai/azure-ai-agents-persistent/tsp-location.yaml b/sdk/ai/azure-ai-agents-persistent/tsp-location.yaml new file mode 100644 index 000000000000..85407855012a --- /dev/null +++ b/sdk/ai/azure-ai-agents-persistent/tsp-location.yaml @@ -0,0 +1,5 @@ +directory: specification/ai/Azure.AI.Agents/ +additionalDirectories: [] +repo: Azure/azure-rest-api-specs +commit: d4efb92b1ec6f76debbb14b4140f79d04bb064d8 + diff --git a/sdk/ai/ci.yml b/sdk/ai/ci.yml index c52361cf6f1b..395df95f01ba 100644 --- a/sdk/ai/ci.yml +++ b/sdk/ai/ci.yml @@ -34,6 +34,10 @@ parameters: displayName: 'azure-ai-inference' type: boolean default: true + - name: release_azureaiagentspersistent + displayName: 'azure-ai-agents-persistent' + type: boolean + default: false extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -44,3 +48,7 @@ extends: groupId: com.azure safeName: azureaiinference releaseInBatch: ${{ parameters.release_azureaiinference }} + - name: azure-ai-agents-persistent + groupId: com.azure + safeName: azureaiagentspersistent + releaseInBatch: ${{ parameters.release_azureaiagentspersistent }} diff --git a/sdk/ai/pom.xml b/sdk/ai/pom.xml index 14915ac80174..340fed2e6346 100644 --- a/sdk/ai/pom.xml +++ b/sdk/ai/pom.xml @@ -11,5 +11,6 @@ azure-ai-inference + azure-ai-agents-persistent From b6c366d393066842e7fde1c90181cef86a138929 Mon Sep 17 00:00:00 2001 From: Jayant Kumar Date: Fri, 9 May 2025 02:48:24 +0530 Subject: [PATCH 2/6] Fix unit tests & build issues --- .vscode/cspell.json | 6 ++++++ sdk/ai/azure-ai-agents-persistent/assets.json | 7 ++++++- .../com/azure/ai/agents/persistent/RunsAsyncClient.java | 4 +--- .../com/azure/ai/agents/persistent/ClientTestBase.java | 8 ++++---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 6c164c64981e..7f164e6e6ad2 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -1366,6 +1366,12 @@ "gcch", "updation" // current typo in a swagger ] + }, + { + "filename": "sdk/ai/azure-ai-agents-persistent/**", + "words": [ + "AISEARCH" + ] } ], "allowCompoundWords": true diff --git a/sdk/ai/azure-ai-agents-persistent/assets.json b/sdk/ai/azure-ai-agents-persistent/assets.json index 82faa1dc490e..cfb691f99239 100644 --- a/sdk/ai/azure-ai-agents-persistent/assets.json +++ b/sdk/ai/azure-ai-agents-persistent/assets.json @@ -1 +1,6 @@ -{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/ai/azure-ai-agents-persistent","Tag":""} \ No newline at end of file +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "java", + "TagPrefix": "java/ai/azure-ai-agents-persistent", + "Tag": "java/ai/azure-ai-agents-persistent_0e2d0e5b6f" +} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java index d2729573c4f0..ba24da39ba29 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java @@ -12,8 +12,8 @@ import com.azure.ai.agents.persistent.models.RunAdditionalFieldList; import com.azure.ai.agents.persistent.models.ThreadRun; import com.azure.ai.agents.persistent.models.ToolOutput; -import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; import com.azure.ai.agents.persistent.models.streaming.PersistentAgentServerSentEvents; +import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -733,7 +733,6 @@ public Mono> createRunStreaming(CreateRunOptions options) { .collect(Collectors.joining(",")), false); } - return createRunWithResponse(threadId, createRunRequest, requestOptions).map(response -> { PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response.getValue().toFluxByteBuffer()); @@ -979,7 +978,6 @@ public Mono> submitToolOutputsToRunStreaming(String threadId, SubmitToolOutputsToRunRequest submitToolOutputsToRunRequestObj = new SubmitToolOutputsToRunRequest(toolOutputs).setStream(true); BinaryData submitToolOutputsToRunRequest = BinaryData.fromObject(submitToolOutputsToRunRequestObj); - return submitToolOutputsToRunWithResponse(threadId, runId, submitToolOutputsToRunRequest, requestOptions) .map(response -> { PersistentAgentServerSentEvents eventStream diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java index cf92bf4b0f17..4b17e539f675 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java @@ -52,10 +52,10 @@ protected PersistentAgentsAdministrationClientBuilder getClientBuilder(HttpClien .credential(new DefaultAzureCredentialBuilder().build()); } - String serviceVersion = Configuration.getGlobalConfiguration().get("SERVICE_VERSION"); - if (serviceVersion != null) { - builder.serviceVersion(AgentsServiceVersion.valueOf(serviceVersion)); - } + String version = Configuration.getGlobalConfiguration().get("SERVICE_VERSION"); + AgentsServiceVersion serviceVersion + = version != null ? AgentsServiceVersion.valueOf(version) : AgentsServiceVersion.V2025_05_15_PREVIEW; + builder.serviceVersion(serviceVersion); return builder; } From 28a5d12a4931a603f8ac8d2de2e087f11d98d527 Mon Sep 17 00:00:00 2001 From: Jayant Kumar Date: Mon, 12 May 2025 13:30:19 +0530 Subject: [PATCH 3/6] feedbacks --- .../ai/agents/persistent/RunsAsyncClient.java | 14 +++---- .../ai/agents/persistent/RunsClient.java | 40 ++++++++++++++++--- .../PersistentAgentServerSentEvents.java | 3 +- .../StreamMessageCreation.java | 5 +-- .../{streaming => }/StreamMessageUpdate.java | 5 +-- .../{streaming => }/StreamRequiredAction.java | 5 +-- .../{streaming => }/StreamRunCreation.java | 5 +-- .../{streaming => }/StreamRunStepUpdate.java | 5 +-- .../{streaming => }/StreamThreadCreation.java | 4 +- .../StreamThreadRunCreation.java | 5 +-- .../{streaming => }/StreamTypeFactory.java | 8 +--- .../models/{streaming => }/StreamUpdate.java | 4 +- .../models/streaming/package-info.java | 8 ---- .../AgentFunctionsStreamingAsyncSample.java | 8 ++-- .../AgentFunctionsStreamingSample.java | 20 +++++----- .../persistent/AgentStreamingAsyncSample.java | 6 +-- .../persistent/AgentStreamingSample.java | 23 +++++------ .../ai/agents/persistent/SampleUtils.java | 2 +- 18 files changed, 80 insertions(+), 90 deletions(-) rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{streaming => }/PersistentAgentServerSentEvents.java (98%) rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{streaming => }/StreamMessageCreation.java (84%) rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{streaming => }/StreamMessageUpdate.java (84%) rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{streaming => }/StreamRequiredAction.java (83%) rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{streaming => }/StreamRunCreation.java (84%) rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{streaming => }/StreamRunStepUpdate.java (83%) rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{streaming => }/StreamThreadCreation.java (88%) rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{streaming => }/StreamThreadRunCreation.java (84%) rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{streaming => }/StreamTypeFactory.java (92%) rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{streaming => }/StreamUpdate.java (88%) delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/package-info.java diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java index ba24da39ba29..6d5c622d2635 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java @@ -12,8 +12,8 @@ import com.azure.ai.agents.persistent.models.RunAdditionalFieldList; import com.azure.ai.agents.persistent.models.ThreadRun; import com.azure.ai.agents.persistent.models.ToolOutput; -import com.azure.ai.agents.persistent.models.streaming.PersistentAgentServerSentEvents; -import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.ai.agents.persistent.models.PersistentAgentServerSentEvents; +import com.azure.ai.agents.persistent.models.StreamUpdate; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -695,7 +695,7 @@ public Mono createRun(CreateRunOptions options) { * Creates a new streaming run for an agent thread. * * @param options Options for createRun API. - * @return A mono of flux streaming updates from the run. + * @return A flux streaming updates from the run. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -704,7 +704,7 @@ public Mono createRun(CreateRunOptions options) { * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createRunStreaming(CreateRunOptions options) { + public Flux createRunStreaming(CreateRunOptions options) { // Generated convenience method for createRunWithResponse RequestOptions requestOptions = new RequestOptions(); String threadId = options.getThreadId(); @@ -733,7 +733,7 @@ public Mono> createRunStreaming(CreateRunOptions options) { .collect(Collectors.joining(",")), false); } - return createRunWithResponse(threadId, createRunRequest, requestOptions).map(response -> { + return createRunWithResponse(threadId, createRunRequest, requestOptions).flatMapMany(response -> { PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response.getValue().toFluxByteBuffer()); return eventStream.getEvents(); @@ -972,14 +972,14 @@ public Mono submitToolOutputsToRun(String threadId, String runId, Lis * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> submitToolOutputsToRunStreaming(String threadId, String runId, + public Flux submitToolOutputsToRunStreaming(String threadId, String runId, List toolOutputs) { RequestOptions requestOptions = new RequestOptions(); SubmitToolOutputsToRunRequest submitToolOutputsToRunRequestObj = new SubmitToolOutputsToRunRequest(toolOutputs).setStream(true); BinaryData submitToolOutputsToRunRequest = BinaryData.fromObject(submitToolOutputsToRunRequestObj); return submitToolOutputsToRunWithResponse(threadId, runId, submitToolOutputsToRunRequest, requestOptions) - .map(response -> { + .flatMapMany(response -> { PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response.getValue().toFluxByteBuffer()); return eventStream.getEvents(); diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java index 7cacef5044c9..f069087a1f1a 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java @@ -12,8 +12,8 @@ import com.azure.ai.agents.persistent.models.RunAdditionalFieldList; import com.azure.ai.agents.persistent.models.ThreadRun; import com.azure.ai.agents.persistent.models.ToolOutput; -import com.azure.ai.agents.persistent.models.streaming.PersistentAgentServerSentEvents; -import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.ai.agents.persistent.models.PersistentAgentServerSentEvents; +import com.azure.ai.agents.persistent.models.StreamUpdate; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -31,6 +31,9 @@ import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; +import com.azure.core.util.logging.ClientLogger; import reactor.core.publisher.Flux; /** @@ -39,6 +42,8 @@ @ServiceClient(builder = PersistentAgentsAdministrationClientBuilder.class) public final class RunsClient { + private final ClientLogger logger = new ClientLogger(RunsClient.class); + @Generated private final RunsImpl serviceClient; @@ -907,7 +912,7 @@ public ThreadRun cancelRun(String threadId, String runId) { * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Flux createRunStreaming(CreateRunOptions options) { + public Stream createRunStreaming(CreateRunOptions options) { // Generated convenience method for createRunWithResponse RequestOptions requestOptions = new RequestOptions(); String threadId = options.getThreadId(); @@ -939,7 +944,19 @@ public Flux createRunStreaming(CreateRunOptions options) { Flux response = createRunWithResponse(threadId, createRunRequest, requestOptions).getValue().toFluxByteBuffer(); PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response); - return eventStream.getEvents(); + + Iterable iterable = eventStream.getEvents().toIterable(); + Stream stream = StreamSupport.stream(iterable.spliterator(), false); + + return stream.onClose(() -> { + if (iterable instanceof AutoCloseable) { + try { + ((AutoCloseable) iterable).close(); + } catch (Exception e) { + throw logger.logExceptionAsError(new RuntimeException(e)); + } + } + }); } /** @@ -959,7 +976,7 @@ public Flux createRunStreaming(CreateRunOptions options) { * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Flux submitToolOutputsToRunStreaming(String threadId, String runId, + public Stream submitToolOutputsToRunStreaming(String threadId, String runId, List toolOutputs) { // Generated convenience method for submitToolOutputsToRunWithResponse RequestOptions requestOptions = new RequestOptions(); @@ -971,7 +988,18 @@ public Flux submitToolOutputsToRunStreaming(String threadId, Strin .getValue() .toFluxByteBuffer(); PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response); - return eventStream.getEvents(); + Iterable iterable = eventStream.getEvents().toIterable(); + Stream stream = StreamSupport.stream(iterable.spliterator(), false); + + return stream.onClose(() -> { + if (iterable instanceof AutoCloseable) { + try { + ((AutoCloseable) iterable).close(); + } catch (Exception e) { + throw logger.logExceptionAsError(new RuntimeException(e)); + } + } + }); } /** diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/PersistentAgentServerSentEvents.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentServerSentEvents.java similarity index 98% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/PersistentAgentServerSentEvents.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentServerSentEvents.java index cfa7772c4199..41f1bfb5394a 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/PersistentAgentServerSentEvents.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentServerSentEvents.java @@ -1,8 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.ai.agents.persistent.models.streaming; +package com.azure.ai.agents.persistent.models; -import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; import com.azure.core.util.BinaryData; import com.azure.core.util.FluxUtil; import com.azure.core.util.logging.ClientLogger; diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageCreation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamMessageCreation.java similarity index 84% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageCreation.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamMessageCreation.java index 798cb50877b0..e79f22d8ad24 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageCreation.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamMessageCreation.java @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.ai.agents.persistent.models.streaming; - -import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; -import com.azure.ai.agents.persistent.models.ThreadMessage; +package com.azure.ai.agents.persistent.models; /** * Represents a stream update indicating a message state change, e.g. creation, completion, etc. diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageUpdate.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamMessageUpdate.java similarity index 84% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageUpdate.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamMessageUpdate.java index 8d18ce3b189a..40385fcc1c68 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamMessageUpdate.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamMessageUpdate.java @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.ai.agents.persistent.models.streaming; - -import com.azure.ai.agents.persistent.models.MessageDeltaChunk; -import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +package com.azure.ai.agents.persistent.models; /** * Represents a stream event indicating an incremental service message update. diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRequiredAction.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamRequiredAction.java similarity index 83% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRequiredAction.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamRequiredAction.java index fe73471d7edb..5201ea98d064 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRequiredAction.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamRequiredAction.java @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.ai.agents.persistent.models.streaming; - -import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; -import com.azure.ai.agents.persistent.models.ThreadRun; +package com.azure.ai.agents.persistent.models; /** * Represents a stream update indicating that input from the user is required. diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunCreation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamRunCreation.java similarity index 84% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunCreation.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamRunCreation.java index 60fca64b2a98..728c1e7fc455 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunCreation.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamRunCreation.java @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.ai.agents.persistent.models.streaming; - -import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; -import com.azure.ai.agents.persistent.models.RunStep; +package com.azure.ai.agents.persistent.models; /** * Represents a stream update indicating a change of state in a run step, e.g. creation, completion, etc. diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunStepUpdate.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamRunStepUpdate.java similarity index 83% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunStepUpdate.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamRunStepUpdate.java index 1896ecc637a7..6787cd9c5307 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamRunStepUpdate.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamRunStepUpdate.java @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.ai.agents.persistent.models.streaming; - -import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; -import com.azure.ai.agents.persistent.models.RunStepDeltaChunk; +package com.azure.ai.agents.persistent.models; /** * Represents a stream update indicating a change of state in a run step, e.g. creation, completion, etc. diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadCreation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamThreadCreation.java similarity index 88% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadCreation.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamThreadCreation.java index 3a9019fad359..e4926a011550 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadCreation.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamThreadCreation.java @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.ai.agents.persistent.models.streaming; - -import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +package com.azure.ai.agents.persistent.models; /** * Represents a stream update that indicating the creation of a new thread. diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadRunCreation.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamThreadRunCreation.java similarity index 84% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadRunCreation.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamThreadRunCreation.java index ba6f9f9d3826..e55b199329f8 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamThreadRunCreation.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamThreadRunCreation.java @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.ai.agents.persistent.models.streaming; - -import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; -import com.azure.ai.agents.persistent.models.ThreadRun; +package com.azure.ai.agents.persistent.models; /** * Represents a stream update indicating a change of state in a thread run, e.g. creation, completion, etc. diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamTypeFactory.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamTypeFactory.java similarity index 92% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamTypeFactory.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamTypeFactory.java index ffe5b0ca6ba9..4163b94b43a5 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamTypeFactory.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamTypeFactory.java @@ -1,13 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.ai.agents.persistent.models.streaming; +package com.azure.ai.agents.persistent.models; -import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; -import com.azure.ai.agents.persistent.models.MessageDeltaChunk; -import com.azure.ai.agents.persistent.models.RunStep; -import com.azure.ai.agents.persistent.models.RunStepDeltaChunk; -import com.azure.ai.agents.persistent.models.ThreadMessage; -import com.azure.ai.agents.persistent.models.ThreadRun; import com.azure.core.util.BinaryData; import com.azure.core.util.logging.ClientLogger; diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamUpdate.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamUpdate.java similarity index 88% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamUpdate.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamUpdate.java index 35f415a8c417..acf283b4ab43 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/StreamUpdate.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/StreamUpdate.java @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.ai.agents.persistent.models.streaming; - -import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; +package com.azure.ai.agents.persistent.models; /** * Parent class for all stream updates types. diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/package-info.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/package-info.java deleted file mode 100644 index ef6818a6402b..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/streaming/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package containing classes for handling streaming updates from AI Project services. - * This package provides models for different types of stream events and updates. - */ -package com.azure.ai.agents.persistent.models.streaming; diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingAsyncSample.java index 584b8f97e3a7..1c7a4c6fd438 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingAsyncSample.java +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingAsyncSample.java @@ -14,10 +14,10 @@ import com.azure.ai.agents.persistent.models.SubmitToolOutputsAction; import com.azure.ai.agents.persistent.models.ThreadRun; import com.azure.ai.agents.persistent.models.ToolOutput; -import com.azure.ai.agents.persistent.models.streaming.StreamMessageUpdate; -import com.azure.ai.agents.persistent.models.streaming.StreamRequiredAction; -import com.azure.ai.agents.persistent.models.streaming.StreamThreadRunCreation; -import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.ai.agents.persistent.models.StreamMessageUpdate; +import com.azure.ai.agents.persistent.models.StreamRequiredAction; +import com.azure.ai.agents.persistent.models.StreamThreadRunCreation; +import com.azure.ai.agents.persistent.models.StreamUpdate; import com.azure.core.util.BinaryData; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java index 7152bc3aaf0f..cfab7b645647 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java @@ -17,10 +17,10 @@ import com.azure.ai.agents.persistent.models.ThreadMessage; import com.azure.ai.agents.persistent.models.ThreadRun; import com.azure.ai.agents.persistent.models.ToolOutput; -import com.azure.ai.agents.persistent.models.streaming.StreamMessageUpdate; -import com.azure.ai.agents.persistent.models.streaming.StreamRequiredAction; -import com.azure.ai.agents.persistent.models.streaming.StreamThreadRunCreation; -import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.ai.agents.persistent.models.StreamMessageUpdate; +import com.azure.ai.agents.persistent.models.StreamRequiredAction; +import com.azure.ai.agents.persistent.models.StreamThreadRunCreation; +import com.azure.ai.agents.persistent.models.StreamUpdate; import com.azure.core.util.BinaryData; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; @@ -37,6 +37,7 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; +import java.util.stream.Stream; import static com.azure.ai.agents.persistent.SampleUtils.printStreamUpdate; @@ -166,10 +167,9 @@ public static void main(String[] args) { .setAdditionalInstructions(""); try { - Flux streamingUpdates = runsClient.createRunStreaming(createRunOptions); + Stream streamUpdates = runsClient.createRunStreaming(createRunOptions); - - streamingUpdates.doOnNext( + streamUpdates.forEach( streamUpdate -> { if (streamUpdate.getKind() == PersistentAgentStreamEvent.THREAD_RUN_CREATED) { System.out.println("----- Run started! -----"); @@ -189,7 +189,7 @@ public static void main(String[] args) { streamRun.get().getThreadId(), streamRun.get().getId(), toolOutputs - ).doOnNext(update -> { + ).forEach(update -> { if (update instanceof StreamRequiredAction) { streamRun.set(((StreamRequiredAction) update).getMessage()); } else if (update instanceof StreamMessageUpdate) { @@ -198,14 +198,14 @@ public static void main(String[] args) { } else if (update.getKind() == PersistentAgentStreamEvent.THREAD_RUN_COMPLETED) { streamRun.set(((StreamThreadRunCreation) update).getMessage()); } - }).blockLast(); + }); } } else if (streamUpdate instanceof StreamMessageUpdate) { StreamMessageUpdate messageUpdate = (StreamMessageUpdate) streamUpdate; printStreamUpdate(messageUpdate); } } - ).blockLast(); + ); System.out.println(); } catch (Exception ex) { diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingAsyncSample.java index 76fa908daedf..a06e6dfceee4 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingAsyncSample.java +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingAsyncSample.java @@ -6,9 +6,9 @@ import com.azure.ai.agents.persistent.models.CreateRunOptions; import com.azure.ai.agents.persistent.models.MessageRole; import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; -import com.azure.ai.agents.persistent.models.streaming.StreamMessageUpdate; -import com.azure.ai.agents.persistent.models.streaming.StreamThreadRunCreation; -import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.ai.agents.persistent.models.StreamMessageUpdate; +import com.azure.ai.agents.persistent.models.StreamThreadRunCreation; +import com.azure.ai.agents.persistent.models.StreamUpdate; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; import reactor.core.publisher.Flux; diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java index 8a162d8fbf4b..6700adcd9b1c 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java @@ -10,12 +10,13 @@ import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; import com.azure.ai.agents.persistent.models.PersistentAgentThread; import com.azure.ai.agents.persistent.models.ThreadMessage; -import com.azure.ai.agents.persistent.models.streaming.StreamMessageUpdate; -import com.azure.ai.agents.persistent.models.streaming.StreamUpdate; +import com.azure.ai.agents.persistent.models.StreamMessageUpdate; +import com.azure.ai.agents.persistent.models.StreamUpdate; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; import reactor.core.publisher.Flux; import java.util.Arrays; +import java.util.stream.Stream; import static com.azure.ai.agents.persistent.SampleUtils.printStreamUpdate; @@ -46,18 +47,16 @@ public static void main(String[] args) { .setAdditionalInstructions(""); try { - Flux streamingUpdates = runsClient.createRunStreaming(createRunOptions); + Stream streamUpdates = runsClient.createRunStreaming(createRunOptions); - streamingUpdates.doOnNext( - streamUpdate -> { - if (streamUpdate.getKind() == PersistentAgentStreamEvent.THREAD_RUN_CREATED) { - System.out.println("----- Run started! -----"); - } else if (streamUpdate instanceof StreamMessageUpdate) { - StreamMessageUpdate messageUpdate = (StreamMessageUpdate) streamUpdate; - printStreamUpdate(messageUpdate); - } + streamUpdates.forEach(streamUpdate -> { + if (streamUpdate.getKind() == PersistentAgentStreamEvent.THREAD_RUN_CREATED) { + System.out.println("----- Run started! -----"); + } else if (streamUpdate instanceof StreamMessageUpdate) { + StreamMessageUpdate messageUpdate = (StreamMessageUpdate) streamUpdate; + printStreamUpdate(messageUpdate); } - ).blockLast(); + }); System.out.println(); } catch (Exception ex) { diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java index 860627282055..fd102ea3944f 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java @@ -10,7 +10,7 @@ import com.azure.ai.agents.persistent.models.RunStatus; import com.azure.ai.agents.persistent.models.ThreadMessage; import com.azure.ai.agents.persistent.models.ThreadRun; -import com.azure.ai.agents.persistent.models.streaming.StreamMessageUpdate; +import com.azure.ai.agents.persistent.models.StreamMessageUpdate; import com.azure.core.http.rest.PagedIterable; import org.jetbrains.annotations.NotNull; import reactor.core.publisher.Mono; From 2a6a62a87ab58da7fe710c12190f636fe598dfbc Mon Sep 17 00:00:00 2001 From: Jayant Kumar Date: Mon, 12 May 2025 14:19:00 +0530 Subject: [PATCH 4/6] updating typespec --- ...tentAgentsAdministrationClientBuilder.java | 23 -- .../ai/agents/persistent/RunsAsyncClient.java | 12 +- .../ai/agents/persistent/RunsClient.java | 9 +- .../models/BingCustomSearchConfiguration.java | 241 ------------------ .../BingCustomSearchConfigurationList.java | 87 ------- .../BingCustomSearchToolDefinition.java | 105 -------- ...ternalPersistentAgentsResponseFormat.java} | 40 +-- .../models/MicrosoftFabricToolDefinition.java | 105 -------- .../models/OpenApiFunctionDefinition.java | 20 ++ .../PersistentAgentsNamedToolChoiceType.java | 18 -- .../RunStepBingCustomSearchToolCall.java | 114 --------- .../RunStepMicrosoftFabricToolCall.java | 114 --------- .../models/RunStepSharepointToolCall.java | 114 --------- .../persistent/models/RunStepToolCall.java | 6 - .../models/SharepointToolDefinition.java | 105 -------- .../persistent/models/ToolConnection.java | 82 ------ .../persistent/models/ToolConnectionList.java | 96 ------- .../persistent/models/ToolDefinition.java | 6 - .../src/main/java/module-info.java | 2 - ...-agents-persistent_apiview_properties.json | 12 +- .../AgentBingCustomSearchAsyncSample.java | 120 --------- .../AgentBingCustomSearchSample.java | 82 ------ .../AgentBingGroundingAsyncSample.java | 4 - .../persistent/AgentBingGroundingSample.java | 4 - .../AgentFabricToolAsyncSample.java | 115 --------- .../persistent/AgentFabricToolSample.java | 71 ------ .../AgentFunctionsStreamingSample.java | 9 +- .../AgentSharepointToolAsyncSample.java | 91 ------- .../persistent/AgentSharepointToolSample.java | 70 ----- .../persistent/AgentStreamingSample.java | 3 +- .../ai/agents/persistent/SampleUtils.java | 2 +- .../ai/agents/persistent/ClientTestBase.java | 5 +- .../tsp-location.yaml | 2 +- 33 files changed, 61 insertions(+), 1828 deletions(-) delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfiguration.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfigurationList.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchToolDefinition.java rename sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/{PersistentAgentsResponseFormat.java => InternalPersistentAgentsResponseFormat.java} (62%) delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MicrosoftFabricToolDefinition.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingCustomSearchToolCall.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMicrosoftFabricToolCall.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepSharepointToolCall.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SharepointToolDefinition.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnection.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnectionList.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchAsyncSample.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchSample.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolAsyncSample.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolSample.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolAsyncSample.java delete mode 100644 sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolSample.java diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClientBuilder.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClientBuilder.java index 02548121b138..bb25267b2c78 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClientBuilder.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/PersistentAgentsAdministrationClientBuilder.java @@ -9,9 +9,7 @@ import com.azure.core.client.traits.ConfigurationTrait; import com.azure.core.client.traits.EndpointTrait; import com.azure.core.client.traits.HttpTrait; -import com.azure.core.client.traits.KeyCredentialTrait; import com.azure.core.client.traits.TokenCredentialTrait; -import com.azure.core.credential.KeyCredential; import com.azure.core.credential.TokenCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.HttpHeaders; @@ -26,7 +24,6 @@ import com.azure.core.http.policy.HttpLoggingPolicy; import com.azure.core.http.policy.HttpPipelinePolicy; import com.azure.core.http.policy.HttpPolicyProviders; -import com.azure.core.http.policy.KeyCredentialPolicy; import com.azure.core.http.policy.RequestIdPolicy; import com.azure.core.http.policy.RetryOptions; import com.azure.core.http.policy.RetryPolicy; @@ -69,7 +66,6 @@ public final class PersistentAgentsAdministrationClientBuilder implements HttpTrait, ConfigurationTrait, TokenCredentialTrait, - KeyCredentialTrait, EndpointTrait { @Generated @@ -222,22 +218,6 @@ public PersistentAgentsAdministrationClientBuilder credential(TokenCredential to return this; } - /* - * The KeyCredential used for authentication. - */ - @Generated - private KeyCredential keyCredential; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public PersistentAgentsAdministrationClientBuilder credential(KeyCredential keyCredential) { - this.keyCredential = keyCredential; - return this; - } - /* * The service endpoint */ @@ -336,9 +316,6 @@ private HttpPipeline createHttpPipeline() { HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); policies.add(new AddDatePolicy()); - if (keyCredential != null) { - policies.add(new KeyCredentialPolicy("authorization", keyCredential, "Bearer")); - } if (tokenCredential != null) { policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); } diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java index 6d5c622d2635..6d6a1832ce8f 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsAsyncClient.java @@ -9,11 +9,11 @@ import com.azure.ai.agents.persistent.implementation.models.UpdateRunRequest; import com.azure.ai.agents.persistent.models.CreateRunOptions; import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.PersistentAgentServerSentEvents; import com.azure.ai.agents.persistent.models.RunAdditionalFieldList; +import com.azure.ai.agents.persistent.models.StreamUpdate; import com.azure.ai.agents.persistent.models.ThreadRun; import com.azure.ai.agents.persistent.models.ToolOutput; -import com.azure.ai.agents.persistent.models.PersistentAgentServerSentEvents; -import com.azure.ai.agents.persistent.models.StreamUpdate; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -704,7 +704,7 @@ public Mono createRun(CreateRunOptions options) { * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Flux createRunStreaming(CreateRunOptions options) { + public Mono> createRunStreaming(CreateRunOptions options) { // Generated convenience method for createRunWithResponse RequestOptions requestOptions = new RequestOptions(); String threadId = options.getThreadId(); @@ -733,7 +733,7 @@ public Flux createRunStreaming(CreateRunOptions options) { .collect(Collectors.joining(",")), false); } - return createRunWithResponse(threadId, createRunRequest, requestOptions).flatMapMany(response -> { + return createRunWithResponse(threadId, createRunRequest, requestOptions).map(response -> { PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response.getValue().toFluxByteBuffer()); return eventStream.getEvents(); @@ -972,14 +972,14 @@ public Mono submitToolOutputsToRun(String threadId, String runId, Lis * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Flux submitToolOutputsToRunStreaming(String threadId, String runId, + public Mono> submitToolOutputsToRunStreaming(String threadId, String runId, List toolOutputs) { RequestOptions requestOptions = new RequestOptions(); SubmitToolOutputsToRunRequest submitToolOutputsToRunRequestObj = new SubmitToolOutputsToRunRequest(toolOutputs).setStream(true); BinaryData submitToolOutputsToRunRequest = BinaryData.fromObject(submitToolOutputsToRunRequestObj); return submitToolOutputsToRunWithResponse(threadId, runId, submitToolOutputsToRunRequest, requestOptions) - .flatMapMany(response -> { + .map(response -> { PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response.getValue().toFluxByteBuffer()); return eventStream.getEvents(); diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java index f069087a1f1a..84217c345c60 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/RunsClient.java @@ -9,11 +9,11 @@ import com.azure.ai.agents.persistent.implementation.models.UpdateRunRequest; import com.azure.ai.agents.persistent.models.CreateRunOptions; import com.azure.ai.agents.persistent.models.ListSortOrder; +import com.azure.ai.agents.persistent.models.PersistentAgentServerSentEvents; import com.azure.ai.agents.persistent.models.RunAdditionalFieldList; +import com.azure.ai.agents.persistent.models.StreamUpdate; import com.azure.ai.agents.persistent.models.ThreadRun; import com.azure.ai.agents.persistent.models.ToolOutput; -import com.azure.ai.agents.persistent.models.PersistentAgentServerSentEvents; -import com.azure.ai.agents.persistent.models.StreamUpdate; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -26,6 +26,7 @@ import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; import java.nio.ByteBuffer; import java.util.List; import java.util.Map; @@ -33,7 +34,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; -import com.azure.core.util.logging.ClientLogger; import reactor.core.publisher.Flux; /** @@ -944,10 +944,8 @@ public Stream createRunStreaming(CreateRunOptions options) { Flux response = createRunWithResponse(threadId, createRunRequest, requestOptions).getValue().toFluxByteBuffer(); PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response); - Iterable iterable = eventStream.getEvents().toIterable(); Stream stream = StreamSupport.stream(iterable.spliterator(), false); - return stream.onClose(() -> { if (iterable instanceof AutoCloseable) { try { @@ -990,7 +988,6 @@ public Stream submitToolOutputsToRunStreaming(String threadId, Str PersistentAgentServerSentEvents eventStream = new PersistentAgentServerSentEvents(response); Iterable iterable = eventStream.getEvents().toIterable(); Stream stream = StreamSupport.stream(iterable.spliterator(), false); - return stream.onClose(() -> { if (iterable instanceof AutoCloseable) { try { diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfiguration.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfiguration.java deleted file mode 100644 index 6adbcc0ab48e..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfiguration.java +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.ai.agents.persistent.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.Generated; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * A bing custom search configuration. - */ -@Fluent -public final class BingCustomSearchConfiguration implements JsonSerializable { - - /* - * Connection id for grounding with bing search - */ - @Generated - private final String connectionId; - - /* - * Name of the custom configuration instance given to config. - */ - @Generated - private final String instanceName; - - /* - * The market where the results come from. - */ - @Generated - private String market; - - /* - * The language to use for user interface strings when calling Bing API. - */ - @Generated - private String setLang; - - /* - * The number of search results to return in the bing api response - */ - @Generated - private Long count; - - /* - * Filter search results by a specific time range. Accepted values: - * https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters - */ - @Generated - private String freshness; - - /** - * Creates an instance of BingCustomSearchConfiguration class. - * - * @param connectionId the connectionId value to set. - * @param instanceName the instanceName value to set. - */ - @Generated - public BingCustomSearchConfiguration(String connectionId, String instanceName) { - this.connectionId = connectionId; - this.instanceName = instanceName; - } - - /** - * Get the connectionId property: Connection id for grounding with bing search. - * - * @return the connectionId value. - */ - @Generated - public String getConnectionId() { - return this.connectionId; - } - - /** - * Get the instanceName property: Name of the custom configuration instance given to config. - * - * @return the instanceName value. - */ - @Generated - public String getInstanceName() { - return this.instanceName; - } - - /** - * Get the market property: The market where the results come from. - * - * @return the market value. - */ - @Generated - public String getMarket() { - return this.market; - } - - /** - * Set the market property: The market where the results come from. - * - * @param market the market value to set. - * @return the BingCustomSearchConfiguration object itself. - */ - @Generated - public BingCustomSearchConfiguration setMarket(String market) { - this.market = market; - return this; - } - - /** - * Get the setLang property: The language to use for user interface strings when calling Bing API. - * - * @return the setLang value. - */ - @Generated - public String getSetLang() { - return this.setLang; - } - - /** - * Set the setLang property: The language to use for user interface strings when calling Bing API. - * - * @param setLang the setLang value to set. - * @return the BingCustomSearchConfiguration object itself. - */ - @Generated - public BingCustomSearchConfiguration setSetLang(String setLang) { - this.setLang = setLang; - return this; - } - - /** - * Get the count property: The number of search results to return in the bing api response. - * - * @return the count value. - */ - @Generated - public Long getCount() { - return this.count; - } - - /** - * Set the count property: The number of search results to return in the bing api response. - * - * @param count the count value to set. - * @return the BingCustomSearchConfiguration object itself. - */ - @Generated - public BingCustomSearchConfiguration setCount(Long count) { - this.count = count; - return this; - } - - /** - * Get the freshness property: Filter search results by a specific time range. Accepted values: - * https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters. - * - * @return the freshness value. - */ - @Generated - public String getFreshness() { - return this.freshness; - } - - /** - * Set the freshness property: Filter search results by a specific time range. Accepted values: - * https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters. - * - * @param freshness the freshness value to set. - * @return the BingCustomSearchConfiguration object itself. - */ - @Generated - public BingCustomSearchConfiguration setFreshness(String freshness) { - this.freshness = freshness; - return this; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("connection_id", this.connectionId); - jsonWriter.writeStringField("instance_name", this.instanceName); - jsonWriter.writeStringField("market", this.market); - jsonWriter.writeStringField("set_lang", this.setLang); - jsonWriter.writeNumberField("count", this.count); - jsonWriter.writeStringField("freshness", this.freshness); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of BingCustomSearchConfiguration from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of BingCustomSearchConfiguration if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the BingCustomSearchConfiguration. - */ - @Generated - public static BingCustomSearchConfiguration fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String connectionId = null; - String instanceName = null; - String market = null; - String setLang = null; - Long count = null; - String freshness = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("connection_id".equals(fieldName)) { - connectionId = reader.getString(); - } else if ("instance_name".equals(fieldName)) { - instanceName = reader.getString(); - } else if ("market".equals(fieldName)) { - market = reader.getString(); - } else if ("set_lang".equals(fieldName)) { - setLang = reader.getString(); - } else if ("count".equals(fieldName)) { - count = reader.getNullable(JsonReader::getLong); - } else if ("freshness".equals(fieldName)) { - freshness = reader.getString(); - } else { - reader.skipChildren(); - } - } - BingCustomSearchConfiguration deserializedBingCustomSearchConfiguration - = new BingCustomSearchConfiguration(connectionId, instanceName); - deserializedBingCustomSearchConfiguration.market = market; - deserializedBingCustomSearchConfiguration.setLang = setLang; - deserializedBingCustomSearchConfiguration.count = count; - deserializedBingCustomSearchConfiguration.freshness = freshness; - return deserializedBingCustomSearchConfiguration; - }); - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfigurationList.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfigurationList.java deleted file mode 100644 index 558c304c215d..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchConfigurationList.java +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.ai.agents.persistent.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.List; - -/** - * A list of search configurations currently used by the `bing_custom_search` tool. - */ -@Immutable -public final class BingCustomSearchConfigurationList implements JsonSerializable { - - /* - * The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - */ - @Generated - private final List searchConfigurations; - - /** - * Creates an instance of BingCustomSearchConfigurationList class. - * - * @param searchConfigurations the searchConfigurations value to set. - */ - @Generated - public BingCustomSearchConfigurationList(List searchConfigurations) { - this.searchConfigurations = searchConfigurations; - } - - /** - * Get the searchConfigurations property: The connections attached to this tool. There can be a maximum of 1 - * connection - * resource attached to the tool. - * - * @return the searchConfigurations value. - */ - @Generated - public List getSearchConfigurations() { - return this.searchConfigurations; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeArrayField("search_configurations", this.searchConfigurations, - (writer, element) -> writer.writeJson(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of BingCustomSearchConfigurationList from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of BingCustomSearchConfigurationList if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the BingCustomSearchConfigurationList. - */ - @Generated - public static BingCustomSearchConfigurationList fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - List searchConfigurations = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("search_configurations".equals(fieldName)) { - searchConfigurations = reader.readArray(reader1 -> BingCustomSearchConfiguration.fromJson(reader1)); - } else { - reader.skipChildren(); - } - } - return new BingCustomSearchConfigurationList(searchConfigurations); - }); - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchToolDefinition.java deleted file mode 100644 index 38421231f5ed..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/BingCustomSearchToolDefinition.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.ai.agents.persistent.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The input definition information for a Bing custom search tool as used to configure an agent. - */ -@Immutable -public final class BingCustomSearchToolDefinition extends ToolDefinition { - - /* - * The object type. - */ - @Generated - private String type = "bing_custom_search"; - - /* - * The list of search configurations used by the bing custom search tool. - */ - @Generated - private final BingCustomSearchConfigurationList bingCustomSearch; - - /** - * Creates an instance of BingCustomSearchToolDefinition class. - * - * @param bingCustomSearch the bingCustomSearch value to set. - */ - @Generated - public BingCustomSearchToolDefinition(BingCustomSearchConfigurationList bingCustomSearch) { - this.bingCustomSearch = bingCustomSearch; - } - - /** - * Get the type property: The object type. - * - * @return the type value. - */ - @Generated - @Override - public String getType() { - return this.type; - } - - /** - * Get the bingCustomSearch property: The list of search configurations used by the bing custom search tool. - * - * @return the bingCustomSearch value. - */ - @Generated - public BingCustomSearchConfigurationList getBingCustomSearch() { - return this.bingCustomSearch; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeJsonField("bing_custom_search", this.bingCustomSearch); - jsonWriter.writeStringField("type", this.type); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of BingCustomSearchToolDefinition from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of BingCustomSearchToolDefinition if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the BingCustomSearchToolDefinition. - */ - @Generated - public static BingCustomSearchToolDefinition fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - BingCustomSearchConfigurationList bingCustomSearch = null; - String type = "bing_custom_search"; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("bing_custom_search".equals(fieldName)) { - bingCustomSearch = BingCustomSearchConfigurationList.fromJson(reader); - } else if ("type".equals(fieldName)) { - type = reader.getString(); - } else { - reader.skipChildren(); - } - } - BingCustomSearchToolDefinition deserializedBingCustomSearchToolDefinition - = new BingCustomSearchToolDefinition(bingCustomSearch); - deserializedBingCustomSearchToolDefinition.type = type; - return deserializedBingCustomSearchToolDefinition; - }); - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormat.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/InternalPersistentAgentsResponseFormat.java similarity index 62% rename from sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormat.java rename to sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/InternalPersistentAgentsResponseFormat.java index 91712bb3d879..6bee99a155fb 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsResponseFormat.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/InternalPersistentAgentsResponseFormat.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.agents.persistent.models; import com.azure.core.annotation.Fluent; @@ -17,8 +18,8 @@ * If `text` the model can return text or any value needed. */ @Fluent -public final class PersistentAgentsResponseFormat implements JsonSerializable { - +public final class InternalPersistentAgentsResponseFormat + implements JsonSerializable { /* * Must be one of `text` or `json_object`. */ @@ -26,15 +27,15 @@ public final class PersistentAgentsResponseFormat implements JsonSerializable { - PersistentAgentsResponseFormat deserializedPersistentAgentsResponseFormat - = new PersistentAgentsResponseFormat(); + InternalPersistentAgentsResponseFormat deserializedInternalPersistentAgentsResponseFormat + = new InternalPersistentAgentsResponseFormat(); while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); + if ("type".equals(fieldName)) { - deserializedPersistentAgentsResponseFormat.type = ResponseFormat.fromString(reader.getString()); + deserializedInternalPersistentAgentsResponseFormat.type + = ResponseFormat.fromString(reader.getString()); } else { reader.skipChildren(); } } - return deserializedPersistentAgentsResponseFormat; + + return deserializedInternalPersistentAgentsResponseFormat; }); } } diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MicrosoftFabricToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MicrosoftFabricToolDefinition.java deleted file mode 100644 index 1ffe075c4b0b..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/MicrosoftFabricToolDefinition.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.ai.agents.persistent.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The input definition information for a Microsoft Fabric tool as used to configure an agent. - */ -@Immutable -public final class MicrosoftFabricToolDefinition extends ToolDefinition { - - /* - * The object type. - */ - @Generated - private String type = "fabric_dataagent"; - - /* - * The list of connections used by the Microsoft Fabric tool. - */ - @Generated - private final ToolConnectionList fabricDataagent; - - /** - * Creates an instance of MicrosoftFabricToolDefinition class. - * - * @param fabricDataagent the fabricDataagent value to set. - */ - @Generated - public MicrosoftFabricToolDefinition(ToolConnectionList fabricDataagent) { - this.fabricDataagent = fabricDataagent; - } - - /** - * Get the type property: The object type. - * - * @return the type value. - */ - @Generated - @Override - public String getType() { - return this.type; - } - - /** - * Get the fabricDataagent property: The list of connections used by the Microsoft Fabric tool. - * - * @return the fabricDataagent value. - */ - @Generated - public ToolConnectionList getFabricDataagent() { - return this.fabricDataagent; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeJsonField("fabric_dataagent", this.fabricDataagent); - jsonWriter.writeStringField("type", this.type); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of MicrosoftFabricToolDefinition from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of MicrosoftFabricToolDefinition if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the MicrosoftFabricToolDefinition. - */ - @Generated - public static MicrosoftFabricToolDefinition fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - ToolConnectionList fabricDataagent = null; - String type = "fabric_dataagent"; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("fabric_dataagent".equals(fieldName)) { - fabricDataagent = ToolConnectionList.fromJson(reader); - } else if ("type".equals(fieldName)) { - type = reader.getString(); - } else { - reader.skipChildren(); - } - } - MicrosoftFabricToolDefinition deserializedMicrosoftFabricToolDefinition - = new MicrosoftFabricToolDefinition(fabricDataagent); - deserializedMicrosoftFabricToolDefinition.type = type; - return deserializedMicrosoftFabricToolDefinition; - }); - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiFunctionDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiFunctionDefinition.java index 69c60c5491da..e30341807bd6 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiFunctionDefinition.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/OpenApiFunctionDefinition.java @@ -173,6 +173,7 @@ public static OpenApiFunctionDefinition fromJson(JsonReader jsonReader) throws I OpenApiAuthDetails auth = null; String description = null; List defaultParams = null; + List functions = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); @@ -186,6 +187,8 @@ public static OpenApiFunctionDefinition fromJson(JsonReader jsonReader) throws I description = reader.getString(); } else if ("default_params".equals(fieldName)) { defaultParams = reader.readArray(reader1 -> reader1.getString()); + } else if ("functions".equals(fieldName)) { + functions = reader.readArray(reader1 -> FunctionDefinition.fromJson(reader1)); } else { reader.skipChildren(); } @@ -194,7 +197,24 @@ public static OpenApiFunctionDefinition fromJson(JsonReader jsonReader) throws I = new OpenApiFunctionDefinition(name, spec, auth); deserializedOpenApiFunctionDefinition.description = description; deserializedOpenApiFunctionDefinition.defaultParams = defaultParams; + deserializedOpenApiFunctionDefinition.functions = functions; return deserializedOpenApiFunctionDefinition; }); } + + /* + * List of function definitions used by OpenApi tool + */ + @Generated + private List functions; + + /** + * Get the functions property: List of function definitions used by OpenApi tool. + * + * @return the functions value. + */ + @Generated + public List getFunctions() { + return this.functions; + } } diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoiceType.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoiceType.java index 765d3ee4f8f0..df8467801538 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoiceType.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/PersistentAgentsNamedToolChoiceType.java @@ -31,24 +31,6 @@ public final class PersistentAgentsNamedToolChoiceType @Generated public static final PersistentAgentsNamedToolChoiceType FILE_SEARCH = fromString("file_search"); - /** - * Tool type `bing_grounding`. - */ - @Generated - public static final PersistentAgentsNamedToolChoiceType BING_GROUNDING = fromString("bing_grounding"); - - /** - * Tool type `fabric_dataagent`. - */ - @Generated - public static final PersistentAgentsNamedToolChoiceType MICROSOFT_FABRIC = fromString("fabric_dataagent"); - - /** - * Tool type `sharepoint_grounding`. - */ - @Generated - public static final PersistentAgentsNamedToolChoiceType SHAREPOINT = fromString("sharepoint_grounding"); - /** * Tool type `azure_ai_search`. */ diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingCustomSearchToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingCustomSearchToolCall.java deleted file mode 100644 index c817f5cef9ee..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepBingCustomSearchToolCall.java +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.ai.agents.persistent.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.Map; - -/** - * A record of a call to a bing custom search tool, issued by the model in evaluation of a defined tool, that represents - * executed search with bing custom search. - */ -@Immutable -public final class RunStepBingCustomSearchToolCall extends RunStepToolCall { - - /* - * The object type. - */ - @Generated - private String type = "bing_custom_search"; - - /* - * Reserved for future use. - */ - @Generated - private final Map bingCustomSearch; - - /** - * Creates an instance of RunStepBingCustomSearchToolCall class. - * - * @param id the id value to set. - * @param bingCustomSearch the bingCustomSearch value to set. - */ - @Generated - private RunStepBingCustomSearchToolCall(String id, Map bingCustomSearch) { - super(id); - this.bingCustomSearch = bingCustomSearch; - } - - /** - * Get the type property: The object type. - * - * @return the type value. - */ - @Generated - @Override - public String getType() { - return this.type; - } - - /** - * Get the bingCustomSearch property: Reserved for future use. - * - * @return the bingCustomSearch value. - */ - @Generated - public Map getBingCustomSearch() { - return this.bingCustomSearch; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("id", getId()); - jsonWriter.writeMapField("bing_custom_search", this.bingCustomSearch, - (writer, element) -> writer.writeString(element)); - jsonWriter.writeStringField("type", this.type); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of RunStepBingCustomSearchToolCall from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of RunStepBingCustomSearchToolCall if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the RunStepBingCustomSearchToolCall. - */ - @Generated - public static RunStepBingCustomSearchToolCall fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - Map bingCustomSearch = null; - String type = "bing_custom_search"; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("bing_custom_search".equals(fieldName)) { - bingCustomSearch = reader.readMap(reader1 -> reader1.getString()); - } else if ("type".equals(fieldName)) { - type = reader.getString(); - } else { - reader.skipChildren(); - } - } - RunStepBingCustomSearchToolCall deserializedRunStepBingCustomSearchToolCall - = new RunStepBingCustomSearchToolCall(id, bingCustomSearch); - deserializedRunStepBingCustomSearchToolCall.type = type; - return deserializedRunStepBingCustomSearchToolCall; - }); - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMicrosoftFabricToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMicrosoftFabricToolCall.java deleted file mode 100644 index 2e9e3ca05d98..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepMicrosoftFabricToolCall.java +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.ai.agents.persistent.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.Map; - -/** - * A record of a call to a Microsoft Fabric tool, issued by the model in evaluation of a defined tool, that represents - * executed Microsoft Fabric operations. - */ -@Immutable -public final class RunStepMicrosoftFabricToolCall extends RunStepToolCall { - - /* - * The object type. - */ - @Generated - private String type = "fabric_dataagent"; - - /* - * Reserved for future use. - */ - @Generated - private final Map microsoftFabric; - - /** - * Creates an instance of RunStepMicrosoftFabricToolCall class. - * - * @param id the id value to set. - * @param microsoftFabric the microsoftFabric value to set. - */ - @Generated - private RunStepMicrosoftFabricToolCall(String id, Map microsoftFabric) { - super(id); - this.microsoftFabric = microsoftFabric; - } - - /** - * Get the type property: The object type. - * - * @return the type value. - */ - @Generated - @Override - public String getType() { - return this.type; - } - - /** - * Get the microsoftFabric property: Reserved for future use. - * - * @return the microsoftFabric value. - */ - @Generated - public Map getMicrosoftFabric() { - return this.microsoftFabric; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("id", getId()); - jsonWriter.writeMapField("fabric_dataagent", this.microsoftFabric, - (writer, element) -> writer.writeString(element)); - jsonWriter.writeStringField("type", this.type); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of RunStepMicrosoftFabricToolCall from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of RunStepMicrosoftFabricToolCall if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the RunStepMicrosoftFabricToolCall. - */ - @Generated - public static RunStepMicrosoftFabricToolCall fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - Map microsoftFabric = null; - String type = "fabric_dataagent"; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("fabric_dataagent".equals(fieldName)) { - microsoftFabric = reader.readMap(reader1 -> reader1.getString()); - } else if ("type".equals(fieldName)) { - type = reader.getString(); - } else { - reader.skipChildren(); - } - } - RunStepMicrosoftFabricToolCall deserializedRunStepMicrosoftFabricToolCall - = new RunStepMicrosoftFabricToolCall(id, microsoftFabric); - deserializedRunStepMicrosoftFabricToolCall.type = type; - return deserializedRunStepMicrosoftFabricToolCall; - }); - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepSharepointToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepSharepointToolCall.java deleted file mode 100644 index fad1bf5df004..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepSharepointToolCall.java +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.ai.agents.persistent.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.Map; - -/** - * A record of a call to a SharePoint tool, issued by the model in evaluation of a defined tool, that represents - * executed SharePoint actions. - */ -@Immutable -public final class RunStepSharepointToolCall extends RunStepToolCall { - - /* - * The object type. - */ - @Generated - private String type = "sharepoint_grounding"; - - /* - * Reserved for future use. - */ - @Generated - private final Map sharePoint; - - /** - * Creates an instance of RunStepSharepointToolCall class. - * - * @param id the id value to set. - * @param sharePoint the sharePoint value to set. - */ - @Generated - private RunStepSharepointToolCall(String id, Map sharePoint) { - super(id); - this.sharePoint = sharePoint; - } - - /** - * Get the type property: The object type. - * - * @return the type value. - */ - @Generated - @Override - public String getType() { - return this.type; - } - - /** - * Get the sharePoint property: Reserved for future use. - * - * @return the sharePoint value. - */ - @Generated - public Map getSharePoint() { - return this.sharePoint; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("id", getId()); - jsonWriter.writeMapField("sharepoint_grounding", this.sharePoint, - (writer, element) -> writer.writeString(element)); - jsonWriter.writeStringField("type", this.type); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of RunStepSharepointToolCall from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of RunStepSharepointToolCall if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the RunStepSharepointToolCall. - */ - @Generated - public static RunStepSharepointToolCall fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - Map sharePoint = null; - String type = "sharepoint_grounding"; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("sharepoint_grounding".equals(fieldName)) { - sharePoint = reader.readMap(reader1 -> reader1.getString()); - } else if ("type".equals(fieldName)) { - type = reader.getString(); - } else { - reader.skipChildren(); - } - } - RunStepSharepointToolCall deserializedRunStepSharepointToolCall - = new RunStepSharepointToolCall(id, sharePoint); - deserializedRunStepSharepointToolCall.type = type; - return deserializedRunStepSharepointToolCall; - }); - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCall.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCall.java index 1ef544d74373..89388d9a2b1c 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCall.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/RunStepToolCall.java @@ -106,12 +106,6 @@ public static RunStepToolCall fromJson(JsonReader jsonReader) throws IOException return RunStepBingGroundingToolCall.fromJson(readerToUse.reset()); } else if ("azure_ai_search".equals(discriminatorValue)) { return RunStepAzureAISearchToolCall.fromJson(readerToUse.reset()); - } else if ("sharepoint_grounding".equals(discriminatorValue)) { - return RunStepSharepointToolCall.fromJson(readerToUse.reset()); - } else if ("fabric_dataagent".equals(discriminatorValue)) { - return RunStepMicrosoftFabricToolCall.fromJson(readerToUse.reset()); - } else if ("bing_custom_search".equals(discriminatorValue)) { - return RunStepBingCustomSearchToolCall.fromJson(readerToUse.reset()); } else if ("function".equals(discriminatorValue)) { return RunStepFunctionToolCall.fromJson(readerToUse.reset()); } else if ("openapi".equals(discriminatorValue)) { diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SharepointToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SharepointToolDefinition.java deleted file mode 100644 index fe7ee6e5cd7a..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/SharepointToolDefinition.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.ai.agents.persistent.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The input definition information for a sharepoint tool as used to configure an agent. - */ -@Immutable -public final class SharepointToolDefinition extends ToolDefinition { - - /* - * The object type. - */ - @Generated - private String type = "sharepoint_grounding"; - - /* - * The list of connections used by the SharePoint tool. - */ - @Generated - private final ToolConnectionList sharepointGrounding; - - /** - * Creates an instance of SharepointToolDefinition class. - * - * @param sharepointGrounding the sharepointGrounding value to set. - */ - @Generated - public SharepointToolDefinition(ToolConnectionList sharepointGrounding) { - this.sharepointGrounding = sharepointGrounding; - } - - /** - * Get the type property: The object type. - * - * @return the type value. - */ - @Generated - @Override - public String getType() { - return this.type; - } - - /** - * Get the sharepointGrounding property: The list of connections used by the SharePoint tool. - * - * @return the sharepointGrounding value. - */ - @Generated - public ToolConnectionList getSharepointGrounding() { - return this.sharepointGrounding; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeJsonField("sharepoint_grounding", this.sharepointGrounding); - jsonWriter.writeStringField("type", this.type); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of SharepointToolDefinition from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of SharepointToolDefinition if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the SharepointToolDefinition. - */ - @Generated - public static SharepointToolDefinition fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - ToolConnectionList sharepointGrounding = null; - String type = "sharepoint_grounding"; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("sharepoint_grounding".equals(fieldName)) { - sharepointGrounding = ToolConnectionList.fromJson(reader); - } else if ("type".equals(fieldName)) { - type = reader.getString(); - } else { - reader.skipChildren(); - } - } - SharepointToolDefinition deserializedSharepointToolDefinition - = new SharepointToolDefinition(sharepointGrounding); - deserializedSharepointToolDefinition.type = type; - return deserializedSharepointToolDefinition; - }); - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnection.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnection.java deleted file mode 100644 index 9904b3ac4a30..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnection.java +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.ai.agents.persistent.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * A connection resource. - */ -@Immutable -public final class ToolConnection implements JsonSerializable { - - /* - * A connection in a ToolConnectionList attached to this tool. - */ - @Generated - private final String connectionId; - - /** - * Creates an instance of ToolConnection class. - * - * @param connectionId the connectionId value to set. - */ - @Generated - public ToolConnection(String connectionId) { - this.connectionId = connectionId; - } - - /** - * Get the connectionId property: A connection in a ToolConnectionList attached to this tool. - * - * @return the connectionId value. - */ - @Generated - public String getConnectionId() { - return this.connectionId; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("connection_id", this.connectionId); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of ToolConnection from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of ToolConnection if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the ToolConnection. - */ - @Generated - public static ToolConnection fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String connectionId = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("connection_id".equals(fieldName)) { - connectionId = reader.getString(); - } else { - reader.skipChildren(); - } - } - return new ToolConnection(connectionId); - }); - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnectionList.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnectionList.java deleted file mode 100644 index 8991a59d0d73..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolConnectionList.java +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. -package com.azure.ai.agents.persistent.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.annotation.Generated; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.List; - -/** - * A set of connection resources currently used by either the `bing_grounding`, `fabric_dataagent`, or - * `sharepoint_grounding` tools. - */ -@Fluent -public final class ToolConnectionList implements JsonSerializable { - - /* - * The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - */ - @Generated - private List connectionList; - - /** - * Creates an instance of ToolConnectionList class. - */ - @Generated - public ToolConnectionList() { - } - - /** - * Get the connectionList property: The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - * - * @return the connectionList value. - */ - @Generated - public List getConnectionList() { - return this.connectionList; - } - - /** - * Set the connectionList property: The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - * - * @param connectionList the connectionList value to set. - * @return the ToolConnectionList object itself. - */ - @Generated - public ToolConnectionList setConnectionList(List connectionList) { - this.connectionList = connectionList; - return this; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeArrayField("connections", this.connectionList, (writer, element) -> writer.writeJson(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of ToolConnectionList from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of ToolConnectionList if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the ToolConnectionList. - */ - @Generated - public static ToolConnectionList fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - ToolConnectionList deserializedToolConnectionList = new ToolConnectionList(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - if ("connections".equals(fieldName)) { - List connectionList = reader.readArray(reader1 -> ToolConnection.fromJson(reader1)); - deserializedToolConnectionList.connectionList = connectionList; - } else { - reader.skipChildren(); - } - } - return deserializedToolConnectionList; - }); - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolDefinition.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolDefinition.java index c174bced2ea0..baed9bf2e6ce 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolDefinition.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/ToolDefinition.java @@ -85,16 +85,10 @@ public static ToolDefinition fromJson(JsonReader jsonReader) throws IOException return FunctionToolDefinition.fromJson(readerToUse.reset()); } else if ("bing_grounding".equals(discriminatorValue)) { return BingGroundingToolDefinition.fromJson(readerToUse.reset()); - } else if ("fabric_dataagent".equals(discriminatorValue)) { - return MicrosoftFabricToolDefinition.fromJson(readerToUse.reset()); - } else if ("sharepoint_grounding".equals(discriminatorValue)) { - return SharepointToolDefinition.fromJson(readerToUse.reset()); } else if ("azure_ai_search".equals(discriminatorValue)) { return AzureAISearchToolDefinition.fromJson(readerToUse.reset()); } else if ("openapi".equals(discriminatorValue)) { return OpenApiToolDefinition.fromJson(readerToUse.reset()); - } else if ("bing_custom_search".equals(discriminatorValue)) { - return BingCustomSearchToolDefinition.fromJson(readerToUse.reset()); } else if ("connected_agent".equals(discriminatorValue)) { return ConnectedAgentToolDefinition.fromJson(readerToUse.reset()); } else if ("azure_function".equals(discriminatorValue)) { diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/module-info.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/module-info.java index d4397c7e4f66..9b92b31d3873 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/module-info.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/module-info.java @@ -7,9 +7,7 @@ exports com.azure.ai.agents.persistent; exports com.azure.ai.agents.persistent.models; - exports com.azure.ai.agents.persistent.models.streaming; opens com.azure.ai.agents.persistent.implementation.models to com.azure.core; opens com.azure.ai.agents.persistent.models to com.azure.core; - opens com.azure.ai.agents.persistent.models.streaming to com.azure.core; } diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/resources/META-INF/azure-ai-agents-persistent_apiview_properties.json b/sdk/ai/azure-ai-agents-persistent/src/main/resources/META-INF/azure-ai-agents-persistent_apiview_properties.json index 435c19c8a182..ad549b9f5999 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/resources/META-INF/azure-ai-agents-persistent_apiview_properties.json +++ b/sdk/ai/azure-ai-agents-persistent/src/main/resources/META-INF/azure-ai-agents-persistent_apiview_properties.json @@ -193,9 +193,6 @@ "com.azure.ai.agents.persistent.models.AzureFunctionDefinition": "Azure.AI.Agents.AzureFunctionDefinition", "com.azure.ai.agents.persistent.models.AzureFunctionStorageQueue": "Azure.AI.Agents.AzureFunctionStorageQueue", "com.azure.ai.agents.persistent.models.AzureFunctionToolDefinition": "Azure.AI.Agents.AzureFunctionToolDefinition", - "com.azure.ai.agents.persistent.models.BingCustomSearchConfiguration": "Azure.AI.Agents.BingCustomSearchConfiguration", - "com.azure.ai.agents.persistent.models.BingCustomSearchConfigurationList": "Azure.AI.Agents.BingCustomSearchConfigurationList", - "com.azure.ai.agents.persistent.models.BingCustomSearchToolDefinition": "Azure.AI.Agents.BingCustomSearchToolDefinition", "com.azure.ai.agents.persistent.models.BingGroundingSearchConfiguration": "Azure.AI.Agents.BingGroundingSearchConfiguration", "com.azure.ai.agents.persistent.models.BingGroundingSearchConfigurationList": "Azure.AI.Agents.BingGroundingSearchConfigurationList", "com.azure.ai.agents.persistent.models.BingGroundingToolDefinition": "Azure.AI.Agents.BingGroundingToolDefinition", @@ -224,6 +221,7 @@ "com.azure.ai.agents.persistent.models.ImageDetailLevel": "Azure.AI.Agents.ImageDetailLevel", "com.azure.ai.agents.persistent.models.IncompleteDetailsReason": "Azure.AI.Agents.IncompleteDetailsReason", "com.azure.ai.agents.persistent.models.IncompleteRunDetails": "Azure.AI.Agents.IncompleteRunDetails", + "com.azure.ai.agents.persistent.models.InternalPersistentAgentsResponseFormat": "Azure.AI.Agents.AgentsResponseFormat", "com.azure.ai.agents.persistent.models.ListSortOrder": "Azure.AI.Agents.ListSortOrder", "com.azure.ai.agents.persistent.models.MessageAttachment": "Azure.AI.Agents.MessageAttachment", "com.azure.ai.agents.persistent.models.MessageBlockType": "Azure.AI.Agents.MessageBlockType", @@ -264,7 +262,6 @@ "com.azure.ai.agents.persistent.models.MessageTextFilePathDetails": "Azure.AI.Agents.MessageTextFilePathDetails", "com.azure.ai.agents.persistent.models.MessageTextUrlCitationAnnotation": "Azure.AI.Agents.MessageTextUrlCitationAnnotation", "com.azure.ai.agents.persistent.models.MessageTextUrlCitationDetails": "Azure.AI.Agents.MessageTextUrlCitationDetails", - "com.azure.ai.agents.persistent.models.MicrosoftFabricToolDefinition": "Azure.AI.Agents.MicrosoftFabricToolDefinition", "com.azure.ai.agents.persistent.models.OpenApiAnonymousAuthDetails": "Azure.AI.Agents.OpenApiAnonymousAuthDetails", "com.azure.ai.agents.persistent.models.OpenApiAuthDetails": "Azure.AI.Agents.OpenApiAuthDetails", "com.azure.ai.agents.persistent.models.OpenApiAuthType": "Azure.AI.Agents.OpenApiAuthType", @@ -280,7 +277,6 @@ "com.azure.ai.agents.persistent.models.PersistentAgentThreadCreationOptions": "Azure.AI.Agents.AgentThreadCreationOptions", "com.azure.ai.agents.persistent.models.PersistentAgentsNamedToolChoice": "Azure.AI.Agents.AgentsNamedToolChoice", "com.azure.ai.agents.persistent.models.PersistentAgentsNamedToolChoiceType": "Azure.AI.Agents.AgentsNamedToolChoiceType", - "com.azure.ai.agents.persistent.models.PersistentAgentsResponseFormat": "Azure.AI.Agents.AgentsResponseFormat", "com.azure.ai.agents.persistent.models.PersistentAgentsResponseFormatMode": "Azure.AI.Agents.AgentsResponseFormatMode", "com.azure.ai.agents.persistent.models.PersistentAgentsToolChoiceOptionMode": "Azure.AI.Agents.AgentsToolChoiceOptionMode", "com.azure.ai.agents.persistent.models.RequiredAction": "Azure.AI.Agents.RequiredAction", @@ -296,7 +292,6 @@ "com.azure.ai.agents.persistent.models.RunStatus": "Azure.AI.Agents.RunStatus", "com.azure.ai.agents.persistent.models.RunStep": "Azure.AI.Agents.RunStep", "com.azure.ai.agents.persistent.models.RunStepAzureAISearchToolCall": "Azure.AI.Agents.RunStepAzureAISearchToolCall", - "com.azure.ai.agents.persistent.models.RunStepBingCustomSearchToolCall": "Azure.AI.Agents.RunStepBingCustomSearchToolCall", "com.azure.ai.agents.persistent.models.RunStepBingGroundingToolCall": "Azure.AI.Agents.RunStepBingGroundingToolCall", "com.azure.ai.agents.persistent.models.RunStepCodeInterpreterImageOutput": "Azure.AI.Agents.RunStepCodeInterpreterImageOutput", "com.azure.ai.agents.persistent.models.RunStepCodeInterpreterImageReference": "Azure.AI.Agents.RunStepCodeInterpreterImageReference", @@ -331,16 +326,13 @@ "com.azure.ai.agents.persistent.models.RunStepFunctionToolCallDetails": "Azure.AI.Agents.RunStepFunctionToolCallDetails", "com.azure.ai.agents.persistent.models.RunStepMessageCreationDetails": "Azure.AI.Agents.RunStepMessageCreationDetails", "com.azure.ai.agents.persistent.models.RunStepMessageCreationReference": "Azure.AI.Agents.RunStepMessageCreationReference", - "com.azure.ai.agents.persistent.models.RunStepMicrosoftFabricToolCall": "Azure.AI.Agents.RunStepMicrosoftFabricToolCall", "com.azure.ai.agents.persistent.models.RunStepOpenApiToolCall": "Azure.AI.Agents.RunStepOpenAPIToolCall", - "com.azure.ai.agents.persistent.models.RunStepSharepointToolCall": "Azure.AI.Agents.RunStepSharepointToolCall", "com.azure.ai.agents.persistent.models.RunStepStatus": "Azure.AI.Agents.RunStepStatus", "com.azure.ai.agents.persistent.models.RunStepStreamEvent": "Azure.AI.Agents.RunStepStreamEvent", "com.azure.ai.agents.persistent.models.RunStepToolCall": "Azure.AI.Agents.RunStepToolCall", "com.azure.ai.agents.persistent.models.RunStepToolCallDetails": "Azure.AI.Agents.RunStepToolCallDetails", "com.azure.ai.agents.persistent.models.RunStepType": "Azure.AI.Agents.RunStepType", "com.azure.ai.agents.persistent.models.RunStreamEvent": "Azure.AI.Agents.RunStreamEvent", - "com.azure.ai.agents.persistent.models.SharepointToolDefinition": "Azure.AI.Agents.SharepointToolDefinition", "com.azure.ai.agents.persistent.models.SubmitToolOutputsAction": "Azure.AI.Agents.SubmitToolOutputsAction", "com.azure.ai.agents.persistent.models.SubmitToolOutputsDetails": "Azure.AI.Agents.SubmitToolOutputsDetails", "com.azure.ai.agents.persistent.models.ThreadDeletionStatus": "Azure.AI.Agents.ThreadDeletionStatus", @@ -348,8 +340,6 @@ "com.azure.ai.agents.persistent.models.ThreadMessageOptions": "Azure.AI.Agents.ThreadMessageOptions", "com.azure.ai.agents.persistent.models.ThreadRun": "Azure.AI.Agents.ThreadRun", "com.azure.ai.agents.persistent.models.ThreadStreamEvent": "Azure.AI.Agents.ThreadStreamEvent", - "com.azure.ai.agents.persistent.models.ToolConnection": "Azure.AI.Agents.ToolConnection", - "com.azure.ai.agents.persistent.models.ToolConnectionList": "Azure.AI.Agents.ToolConnectionList", "com.azure.ai.agents.persistent.models.ToolDefinition": "Azure.AI.Agents.ToolDefinition", "com.azure.ai.agents.persistent.models.ToolOutput": "Azure.AI.Agents.ToolOutput", "com.azure.ai.agents.persistent.models.ToolResources": "Azure.AI.Agents.ToolResources", diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchAsyncSample.java deleted file mode 100644 index c0fb6616f0f8..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchAsyncSample.java +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.ai.agents.persistent; - -import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; -import com.azure.ai.agents.persistent.models.BingCustomSearchConfiguration; -import com.azure.ai.agents.persistent.models.BingCustomSearchConfigurationList; -import com.azure.ai.agents.persistent.models.BingCustomSearchToolDefinition; -import com.azure.ai.agents.persistent.models.CreateRunOptions; -import com.azure.ai.agents.persistent.models.MessageRole; -import com.azure.ai.agents.persistent.models.PersistentAgent; -import com.azure.ai.agents.persistent.models.ToolConnection; -import com.azure.ai.agents.persistent.models.ToolConnectionList; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Configuration; -import com.azure.identity.DefaultAzureCredentialBuilder; -import java.util.Arrays; -import java.util.concurrent.atomic.AtomicReference; - -import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; -import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; - -public class AgentBingCustomSearchAsyncSample { - - public static void main(String[] args) { - PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() - .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .credential(new DefaultAzureCredentialBuilder().build()); - - PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); - ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); - MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); - RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); - - String bingConnectionId = Configuration.getGlobalConfiguration().get("BING_SEARCH_CONNECTION_ID", ""); - String bingConfigurationId = Configuration.getGlobalConfiguration().get("BING_SEARCH_CONFIGURATION_ID", ""); - - ToolConnectionList toolConnectionList = new ToolConnectionList() - .setConnectionList(Arrays.asList(new ToolConnection(bingConnectionId))); - - BingCustomSearchConfiguration searchConfiguration = new BingCustomSearchConfiguration(bingConnectionId, bingConfigurationId); - BingCustomSearchConfigurationList searchConfigurationList = new BingCustomSearchConfigurationList(Arrays.asList(searchConfiguration)); - - BingCustomSearchToolDefinition bingCustomSearchToolDefinition = new BingCustomSearchToolDefinition(searchConfigurationList); - - String agentName = "bing_custom_search_example_async"; - CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o-mini") - .setName(agentName) - .setInstructions("You are a helpful agent") - .setTools(Arrays.asList(bingCustomSearchToolDefinition)); - - RequestOptions requestOptions = new RequestOptions() - .setHeader("x-ms-enable-preview", "true"); - - // Track resources for cleanup - AtomicReference agentId = new AtomicReference<>(); - AtomicReference threadId = new AtomicReference<>(); - - // Create full reactive chain - agentsAsyncClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) - .flatMap(response -> { - PersistentAgent agent = response.getValue().toObject(PersistentAgent.class); - System.out.println("Created agent: " + agent.getId()); - agentId.set(agent.getId()); - - return threadsAsyncClient.createThread() - .flatMap(thread -> { - System.out.println("Created thread: " + thread.getId()); - threadId.set(thread.getId()); - - // Create initial message - return messagesAsyncClient.createMessage( - thread.getId(), - MessageRole.USER, - "How does wikipedia explain Euler's Identity?" - ).flatMap(message -> { - System.out.println("Created initial message"); - - // Create run - CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) - .setAdditionalInstructions(""); - - return runsAsyncClient.createRun(createRunOptions) - .flatMap(threadRun -> { - System.out.println("Created run, waiting for completion..."); - return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); - }) - .flatMap(completedRun -> { - System.out.println("Run completed with status: " + completedRun.getStatus()); - return printRunMessagesAsync(messagesAsyncClient, thread.getId()); - }); - }); - }); - }) - .doFinally(signalType -> { - // Always clean up resources regardless of success or failure - System.out.println("Cleaning up resources..."); - - // Clean up thread if created - if (threadId.get() != null) { - threadsAsyncClient.deleteThread(threadId.get()) - .doOnSuccess(ignored -> System.out.println("Thread deleted: " + threadId.get())) - .doOnError(error -> System.err.println("Failed to delete thread: " + error.getMessage())) - .subscribe(); - } - - // Clean up agent if created - if (agentId.get() != null) { - agentsAsyncClient.deleteAgent(agentId.get()) - .doOnSuccess(ignored -> System.out.println("Agent deleted: " + agentId.get())) - .doOnError(error -> System.err.println("Failed to delete agent: " + error.getMessage())) - .subscribe(); - } - }) - .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) - .block(); // Only block at the end of the reactive chain - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchSample.java deleted file mode 100644 index 3bf3fdeee6e6..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingCustomSearchSample.java +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.ai.agents.persistent; - -import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; -import com.azure.ai.agents.persistent.models.BingCustomSearchConfiguration; -import com.azure.ai.agents.persistent.models.BingCustomSearchConfigurationList; -import com.azure.ai.agents.persistent.models.BingCustomSearchToolDefinition; -import com.azure.ai.agents.persistent.models.CreateRunOptions; -import com.azure.ai.agents.persistent.models.MessageRole; -import com.azure.ai.agents.persistent.models.PersistentAgent; -import com.azure.ai.agents.persistent.models.PersistentAgentThread; -import com.azure.ai.agents.persistent.models.ThreadMessage; -import com.azure.ai.agents.persistent.models.ThreadRun; -import com.azure.ai.agents.persistent.models.ToolConnection; -import com.azure.ai.agents.persistent.models.ToolConnectionList; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Configuration; -import com.azure.identity.DefaultAzureCredentialBuilder; -import java.util.Arrays; - -import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; -import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; - - -public class AgentBingCustomSearchSample { - - public static void main(String[] args) { - - PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .credential(new DefaultAzureCredentialBuilder().build()); - PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); - ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); - MessagesClient messagesClient = clientBuilder.buildMessagesClient(); - RunsClient runsClient = clientBuilder.buildRunsClient(); - - String bingConnectionId = Configuration.getGlobalConfiguration().get("BING_SEARCH_CONNECTION_ID", ""); - String bingConfigurationId = Configuration.getGlobalConfiguration().get("BING_SEARCH_CONFIGURATION_ID", ""); - - ToolConnectionList toolConnectionList = new ToolConnectionList() - .setConnectionList(Arrays.asList(new ToolConnection(bingConnectionId))); - - BingCustomSearchConfiguration searchConfiguration = new BingCustomSearchConfiguration(bingConnectionId, bingConfigurationId); - BingCustomSearchConfigurationList searchConfigurationList = new BingCustomSearchConfigurationList(Arrays.asList(searchConfiguration)); - - BingCustomSearchToolDefinition bingCustomSearchToolDefinition = new BingCustomSearchToolDefinition(searchConfigurationList); - - String agentName = "bing_custom_search_example"; - CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o-mini") - .setName(agentName) - .setInstructions("You are a helpful agent") - .setTools(Arrays.asList(bingCustomSearchToolDefinition)); - RequestOptions requestOptions = new RequestOptions() - .setHeader("x-ms-enable-preview", "true"); - PersistentAgent agent = agentsClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) - .getValue().toObject(PersistentAgent.class); - - PersistentAgentThread thread = threadsClient.createThread(); - ThreadMessage createdMessage = messagesClient.createMessage( - thread.getId(), - MessageRole.USER, - "How does wikipedia explain Euler's Identity?"); - - try { - //run agent - CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) - .setAdditionalInstructions(""); - ThreadRun threadRun = runsClient.createRun(createRunOptions); - - waitForRunCompletion(thread.getId(), threadRun, runsClient); - printRunMessages(messagesClient, thread.getId()); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } finally { - //cleanup - threadsClient.deleteThread(thread.getId()); - agentsClient.deleteAgent(agent.getId()); - } - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingAsyncSample.java index e5334a0102bc..8a5a2beb2588 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingAsyncSample.java +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingAsyncSample.java @@ -8,8 +8,6 @@ import com.azure.ai.agents.persistent.models.CreateAgentOptions; import com.azure.ai.agents.persistent.models.CreateRunOptions; import com.azure.ai.agents.persistent.models.MessageRole; -import com.azure.ai.agents.persistent.models.ToolConnection; -import com.azure.ai.agents.persistent.models.ToolConnectionList; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; import java.util.Arrays; @@ -32,8 +30,6 @@ public static void main(String[] args) { RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); String bingConnectionId = Configuration.getGlobalConfiguration().get("BING_CONNECTION_ID", ""); - ToolConnectionList toolConnectionList = new ToolConnectionList() - .setConnectionList(Arrays.asList(new ToolConnection(bingConnectionId))); BingGroundingSearchConfiguration searchConfiguration = new BingGroundingSearchConfiguration(bingConnectionId); BingGroundingSearchConfigurationList searchConfigurationList = new BingGroundingSearchConfigurationList( diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingSample.java index 988cae9d868f..efb042a24d70 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingSample.java +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentBingGroundingSample.java @@ -12,8 +12,6 @@ import com.azure.ai.agents.persistent.models.PersistentAgentThread; import com.azure.ai.agents.persistent.models.ThreadMessage; import com.azure.ai.agents.persistent.models.ThreadRun; -import com.azure.ai.agents.persistent.models.ToolConnection; -import com.azure.ai.agents.persistent.models.ToolConnectionList; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; import java.util.Arrays; @@ -33,8 +31,6 @@ public static void main(String[] args) { RunsClient runsClient = clientBuilder.buildRunsClient(); String bingConnectionId = Configuration.getGlobalConfiguration().get("BING_CONNECTION_ID", ""); - ToolConnectionList toolConnectionList = new ToolConnectionList() - .setConnectionList(Arrays.asList(new ToolConnection(bingConnectionId))); BingGroundingSearchConfiguration searchConfiguration = new BingGroundingSearchConfiguration(bingConnectionId); BingGroundingSearchConfigurationList searchConfigurationList = new BingGroundingSearchConfigurationList(Arrays.asList(searchConfiguration)); diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolAsyncSample.java deleted file mode 100644 index ac5a3cee87e8..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolAsyncSample.java +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.ai.agents.persistent; - -import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; -import com.azure.ai.agents.persistent.models.CreateRunOptions; -import com.azure.ai.agents.persistent.models.MessageRole; -import com.azure.ai.agents.persistent.models.MicrosoftFabricToolDefinition; -import com.azure.ai.agents.persistent.models.PersistentAgent; -import com.azure.ai.agents.persistent.models.ToolConnection; -import com.azure.ai.agents.persistent.models.ToolConnectionList; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Configuration; -import com.azure.identity.DefaultAzureCredentialBuilder; -import java.util.Arrays; -import java.util.concurrent.atomic.AtomicReference; - -import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; -import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; - -public final class AgentFabricToolAsyncSample { - - public static void main(String[] args) { - // Initialize async clients - PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() - .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .credential(new DefaultAzureCredentialBuilder().build()); - - PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); - ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); - MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); - RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); - - // Track resources for cleanup - AtomicReference agentId = new AtomicReference<>(); - AtomicReference threadId = new AtomicReference<>(); - - // Get Fabric connection ID from configuration - String fabricConnectionId = Configuration.getGlobalConfiguration().get("FABRIC_CONNECTION_ID", ""); - System.out.println("Using Fabric connection ID: " + fabricConnectionId); - - // Create tool connections list with Fabric connection - ToolConnectionList toolConnectionList = new ToolConnectionList() - .setConnectionList(Arrays.asList(new ToolConnection(fabricConnectionId))); - - // Create Fabric tool definition - MicrosoftFabricToolDefinition fabricToolDefinition = new MicrosoftFabricToolDefinition(toolConnectionList); - - // Create agent request with Fabric tool - String agentName = "fabric_tool_async_example"; - RequestOptions requestOptions = new RequestOptions().setHeader("x-ms-enable-preview", "true"); - CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o-mini") - .setName(agentName) - .setInstructions("You are a helpful agent specialized in querying Microsoft Fabric data") - .setTools(Arrays.asList(fabricToolDefinition)); - - // Create agent with Fabric tool - agentsAsyncClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) - .flatMap(response -> { - // Extract agent from response - PersistentAgent agent = - response.getValue().toObject(PersistentAgent.class); - agentId.set(agent.getId()); - System.out.println("Created agent: " + agent.getId()); - - // Create a thread - return threadsAsyncClient.createThread(); - }) - .flatMap(thread -> { - threadId.set(thread.getId()); - System.out.println("Created thread: " + thread.getId()); - - // Create message - return messagesAsyncClient.createMessage( - thread.getId(), - MessageRole.USER, - "Give me any row from DailyActivity table from connected fabric usage metrics source"); - }) - .flatMap(message -> { - System.out.println("Created message"); - - // Create and start the run - CreateRunOptions createRunOptions = new CreateRunOptions(threadId.get(), agentId.get()) - .setAdditionalInstructions("Please provide detailed information from the Fabric data"); - - return runsAsyncClient.createRun(createRunOptions) - .flatMap(threadRun -> { - System.out.println("Created run, waiting for completion..."); - return waitForRunCompletionAsync(threadId.get(), threadRun, runsAsyncClient); - }) - .flatMap(completedRun -> { - System.out.println("Run completed with status: " + completedRun.getStatus()); - return printRunMessagesAsync(messagesAsyncClient, threadId.get()); - }); - }) - .doFinally(signalType -> { - System.out.println("Cleaning up resources..."); - - // Delete thread - if (threadId.get() != null) { - threadsAsyncClient.deleteThread(threadId.get()).block(); - System.out.println("Deleted thread: " + threadId.get()); - } - - // Delete agent - if (agentId.get() != null) { - agentsAsyncClient.deleteAgent(agentId.get()).block(); - System.out.println("Deleted agent: " + agentId.get()); - } - }) - .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) - .block(); // Only block at the end of the reactive chain - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolSample.java deleted file mode 100644 index d52dbe4a461e..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFabricToolSample.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.ai.agents.persistent; - -import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; -import com.azure.ai.agents.persistent.models.CreateRunOptions; -import com.azure.ai.agents.persistent.models.MessageRole; -import com.azure.ai.agents.persistent.models.MicrosoftFabricToolDefinition; -import com.azure.ai.agents.persistent.models.PersistentAgent; -import com.azure.ai.agents.persistent.models.PersistentAgentThread; -import com.azure.ai.agents.persistent.models.ThreadMessage; -import com.azure.ai.agents.persistent.models.ThreadRun; -import com.azure.ai.agents.persistent.models.ToolConnection; -import com.azure.ai.agents.persistent.models.ToolConnectionList; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Configuration; -import com.azure.identity.DefaultAzureCredentialBuilder; -import java.util.Arrays; - -import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; -import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; - -public final class AgentFabricToolSample { - - public static void main(String[] args) { - - PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .credential(new DefaultAzureCredentialBuilder().build()); - PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); - ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); - MessagesClient messagesClient = clientBuilder.buildMessagesClient(); - RunsClient runsClient = clientBuilder.buildRunsClient(); - - String fabricConnectionId = Configuration.getGlobalConfiguration().get("FABRIC_CONNECTION_ID", ""); - ToolConnectionList toolConnectionList = new ToolConnectionList() - .setConnectionList(Arrays.asList(new ToolConnection(fabricConnectionId))); - MicrosoftFabricToolDefinition fabricToolDefinition = new MicrosoftFabricToolDefinition(toolConnectionList); - - String agentName = "fabric_tool_example"; - RequestOptions requestOptions = new RequestOptions().setHeader("x-ms-enable-preview", "true"); - CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o-mini") - .setName(agentName) - .setInstructions("You are a helpful agent") - .setTools(Arrays.asList(fabricToolDefinition)); - PersistentAgent agent = agentsClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) - .getValue().toObject(PersistentAgent.class); - - PersistentAgentThread thread = threadsClient.createThread(); - ThreadMessage createdMessage = messagesClient.createMessage( - thread.getId(), - MessageRole.USER, - "Give me any row from DailyActivity table from connected fabric usage metrics source"); - - try { - //run agent - CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) - .setAdditionalInstructions(""); - ThreadRun threadRun = runsClient.createRun(createRunOptions); - - waitForRunCompletion(thread.getId(), threadRun, runsClient); - printRunMessages(messagesClient, thread.getId()); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } finally { - //cleanup - threadsClient.deleteThread(thread.getId()); - agentsClient.deleteAgent(agent.getId()); - } - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java index cfab7b645647..9053d0a96197 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentFunctionsStreamingSample.java @@ -13,21 +13,20 @@ import com.azure.ai.agents.persistent.models.RequiredFunctionToolCall; import com.azure.ai.agents.persistent.models.RequiredToolCall; import com.azure.ai.agents.persistent.models.RunStatus; -import com.azure.ai.agents.persistent.models.SubmitToolOutputsAction; -import com.azure.ai.agents.persistent.models.ThreadMessage; -import com.azure.ai.agents.persistent.models.ThreadRun; -import com.azure.ai.agents.persistent.models.ToolOutput; import com.azure.ai.agents.persistent.models.StreamMessageUpdate; import com.azure.ai.agents.persistent.models.StreamRequiredAction; import com.azure.ai.agents.persistent.models.StreamThreadRunCreation; import com.azure.ai.agents.persistent.models.StreamUpdate; +import com.azure.ai.agents.persistent.models.SubmitToolOutputsAction; +import com.azure.ai.agents.persistent.models.ThreadMessage; +import com.azure.ai.agents.persistent.models.ThreadRun; +import com.azure.ai.agents.persistent.models.ToolOutput; import com.azure.core.util.BinaryData; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.json.JsonMapper; -import reactor.core.publisher.Flux; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolAsyncSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolAsyncSample.java deleted file mode 100644 index 7739ce9517e3..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolAsyncSample.java +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.ai.agents.persistent; - -import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; -import com.azure.ai.agents.persistent.models.CreateRunOptions; -import com.azure.ai.agents.persistent.models.MessageRole; -import com.azure.ai.agents.persistent.models.MicrosoftFabricToolDefinition; -import com.azure.ai.agents.persistent.models.PersistentAgent; -import com.azure.ai.agents.persistent.models.ToolConnection; -import com.azure.ai.agents.persistent.models.ToolConnectionList; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Configuration; -import com.azure.identity.DefaultAzureCredentialBuilder; -import java.util.Arrays; -import java.util.concurrent.atomic.AtomicReference; - -import static com.azure.ai.agents.persistent.SampleUtils.cleanUpResources; -import static com.azure.ai.agents.persistent.SampleUtils.printRunMessagesAsync; -import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletionAsync; - -public final class AgentSharepointToolAsyncSample { - - public static void main(String[] args) { - PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder() - .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .credential(new DefaultAzureCredentialBuilder().build()); - - PersistentAgentsAdministrationAsyncClient agentsAsyncClient = clientBuilder.buildAsyncClient(); - ThreadsAsyncClient threadsAsyncClient = clientBuilder.buildThreadsAsyncClient(); - MessagesAsyncClient messagesAsyncClient = clientBuilder.buildMessagesAsyncClient(); - RunsAsyncClient runsAsyncClient = clientBuilder.buildRunsAsyncClient(); - - String sharepointConnectionId = Configuration.getGlobalConfiguration().get("SHAREPOINT_CONNECTION_ID", ""); - ToolConnectionList toolConnectionList = new ToolConnectionList() - .setConnectionList(Arrays.asList(new ToolConnection(sharepointConnectionId))); - MicrosoftFabricToolDefinition fabricToolDefinition = new MicrosoftFabricToolDefinition(toolConnectionList); - - String agentName = "sharepoint_tool_async_example"; - RequestOptions requestOptions = new RequestOptions().setHeader("x-ms-enable-preview", "true"); - CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o") - .setName(agentName) - .setInstructions("You are a helpful agent") - .setTools(Arrays.asList(fabricToolDefinition)); - - // Track resources for cleanup - AtomicReference agentId = new AtomicReference<>(); - AtomicReference threadId = new AtomicReference<>(); - - // Create full reactive chain - agentsAsyncClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) - .map(response -> { - PersistentAgent agent = response.getValue().toObject(PersistentAgent.class); - System.out.println("Created agent: " + agent.getId()); - agentId.set(agent.getId()); - return agent; - }) - .flatMap(agent -> threadsAsyncClient.createThread()) - .flatMap(thread -> { - System.out.println("Created thread: " + thread.getId()); - threadId.set(thread.getId()); - - // Create initial message - return messagesAsyncClient.createMessage( - thread.getId(), - MessageRole.USER, - "Give me summary of the document in the sharepoint site" - ).flatMap(message -> { - System.out.println("Created initial message"); - - // Create and start the run - CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agentId.get()) - .setAdditionalInstructions(""); - - return runsAsyncClient.createRun(createRunOptions) - .flatMap(threadRun -> { - System.out.println("Created run, waiting for completion..."); - return waitForRunCompletionAsync(thread.getId(), threadRun, runsAsyncClient); - }) - .flatMap(completedRun -> { - System.out.println("Run completed with status: " + completedRun.getStatus()); - return printRunMessagesAsync(messagesAsyncClient, thread.getId()); - }); - }); - }) - .doFinally(signalType -> cleanUpResources(threadId, threadsAsyncClient, agentId, agentsAsyncClient)) - .doOnError(error -> System.err.println("An error occurred: " + error.getMessage())) - .block(); // Only block at the end of the reactive chain - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolSample.java deleted file mode 100644 index f09e61bb50bc..000000000000 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentSharepointToolSample.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.ai.agents.persistent; - -import com.azure.ai.agents.persistent.implementation.models.CreateAgentRequest; -import com.azure.ai.agents.persistent.models.CreateRunOptions; -import com.azure.ai.agents.persistent.models.MessageRole; -import com.azure.ai.agents.persistent.models.MicrosoftFabricToolDefinition; -import com.azure.ai.agents.persistent.models.PersistentAgent; -import com.azure.ai.agents.persistent.models.PersistentAgentThread; -import com.azure.ai.agents.persistent.models.ThreadMessage; -import com.azure.ai.agents.persistent.models.ThreadRun; -import com.azure.ai.agents.persistent.models.ToolConnection; -import com.azure.ai.agents.persistent.models.ToolConnectionList; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Configuration; -import com.azure.identity.DefaultAzureCredentialBuilder; -import java.util.Arrays; - -import static com.azure.ai.agents.persistent.SampleUtils.printRunMessages; -import static com.azure.ai.agents.persistent.SampleUtils.waitForRunCompletion; - -public final class AgentSharepointToolSample { - - public static void main(String[] args) { - PersistentAgentsAdministrationClientBuilder clientBuilder = new PersistentAgentsAdministrationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .credential(new DefaultAzureCredentialBuilder().build()); - PersistentAgentsAdministrationClient agentsClient = clientBuilder.buildClient(); - ThreadsClient threadsClient = clientBuilder.buildThreadsClient(); - MessagesClient messagesClient = clientBuilder.buildMessagesClient(); - RunsClient runsClient = clientBuilder.buildRunsClient(); - - String sharepointConnectionId = Configuration.getGlobalConfiguration().get("SHAREPOINT_CONNECTION_ID", ""); - ToolConnectionList toolConnectionList = new ToolConnectionList() - .setConnectionList(Arrays.asList(new ToolConnection(sharepointConnectionId))); - MicrosoftFabricToolDefinition fabricToolDefinition = new MicrosoftFabricToolDefinition(toolConnectionList); - - String agentName = "sharepoint_tool_example"; - RequestOptions requestOptions = new RequestOptions().setHeader("x-ms-enable-preview", "true"); - CreateAgentRequest createAgentRequest = new CreateAgentRequest("gpt-4o") - .setName(agentName) - .setInstructions("You are a helpful agent") - .setTools(Arrays.asList(fabricToolDefinition)); - PersistentAgent agent = agentsClient.createAgentWithResponse(BinaryData.fromObject(createAgentRequest), requestOptions) - .getValue().toObject(PersistentAgent.class); - - PersistentAgentThread thread = threadsClient.createThread(); - ThreadMessage createdMessage = messagesClient.createMessage( - thread.getId(), - MessageRole.USER, - "Give me summary of the document in the sharepoint site"); - - try { - //run agent - CreateRunOptions createRunOptions = new CreateRunOptions(thread.getId(), agent.getId()) - .setAdditionalInstructions(""); - ThreadRun threadRun = runsClient.createRun(createRunOptions); - - waitForRunCompletion(thread.getId(), threadRun, runsClient); - printRunMessages(messagesClient, thread.getId()); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } finally { - //cleanup - threadsClient.deleteThread(thread.getId()); - agentsClient.deleteAgent(agent.getId()); - } - } -} diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java index 6700adcd9b1c..353b9ccab076 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/AgentStreamingSample.java @@ -9,12 +9,11 @@ import com.azure.ai.agents.persistent.models.PersistentAgent; import com.azure.ai.agents.persistent.models.PersistentAgentStreamEvent; import com.azure.ai.agents.persistent.models.PersistentAgentThread; -import com.azure.ai.agents.persistent.models.ThreadMessage; import com.azure.ai.agents.persistent.models.StreamMessageUpdate; import com.azure.ai.agents.persistent.models.StreamUpdate; +import com.azure.ai.agents.persistent.models.ThreadMessage; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; -import reactor.core.publisher.Flux; import java.util.Arrays; import java.util.stream.Stream; diff --git a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java index fd102ea3944f..2fb96f638af0 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java +++ b/sdk/ai/azure-ai-agents-persistent/src/samples/java/com/azure/ai/agents/persistent/SampleUtils.java @@ -8,9 +8,9 @@ import com.azure.ai.agents.persistent.models.MessageImageFileContent; import com.azure.ai.agents.persistent.models.MessageTextContent; import com.azure.ai.agents.persistent.models.RunStatus; +import com.azure.ai.agents.persistent.models.StreamMessageUpdate; import com.azure.ai.agents.persistent.models.ThreadMessage; import com.azure.ai.agents.persistent.models.ThreadRun; -import com.azure.ai.agents.persistent.models.StreamMessageUpdate; import com.azure.core.http.rest.PagedIterable; import org.jetbrains.annotations.NotNull; import reactor.core.publisher.Mono; diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java index 4b17e539f675..f1f71a12a53e 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/ClientTestBase.java @@ -5,20 +5,19 @@ import com.azure.ai.agents.persistent.models.PersistentAgent; import com.azure.ai.agents.persistent.models.RunStatus; import com.azure.ai.agents.persistent.models.ThreadRun; -import com.azure.core.credential.AzureKeyCredential; import com.azure.core.http.HttpClient; import com.azure.core.test.TestMode; import com.azure.core.test.TestProxyTestBase; import com.azure.core.test.models.CustomMatcher; import com.azure.core.test.models.TestProxySanitizer; import com.azure.core.test.models.TestProxySanitizerType; +import com.azure.core.test.utils.MockTokenCredential; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; import reactor.core.publisher.Mono; import java.util.ArrayList; import java.util.Arrays; -import static com.azure.ai.agents.persistent.TestUtils.FAKE_API_KEY; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.fail; @@ -42,7 +41,7 @@ protected PersistentAgentsAdministrationClientBuilder getClientBuilder(HttpClien } if (testMode == TestMode.PLAYBACK) { - builder.endpoint("https://localhost:8080").credential(new AzureKeyCredential(FAKE_API_KEY)); + builder.endpoint("https://localhost:8080").credential(new MockTokenCredential()); } else if (testMode == TestMode.RECORD) { builder.addPolicy(interceptorManager.getRecordPolicy()) .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) diff --git a/sdk/ai/azure-ai-agents-persistent/tsp-location.yaml b/sdk/ai/azure-ai-agents-persistent/tsp-location.yaml index 85407855012a..a86f1de911b6 100644 --- a/sdk/ai/azure-ai-agents-persistent/tsp-location.yaml +++ b/sdk/ai/azure-ai-agents-persistent/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/ai/Azure.AI.Agents/ additionalDirectories: [] repo: Azure/azure-rest-api-specs -commit: d4efb92b1ec6f76debbb14b4140f79d04bb064d8 +commit: 42ca80e5b8ac08c4f90e420b54d2208e64d419a4 From 7c1d0cc2fe6b035113d23a7421d33f076d061779 Mon Sep 17 00:00:00 2001 From: Jayant Kumar Date: Tue, 13 May 2025 00:32:53 +0530 Subject: [PATCH 5/6] build analyze issue - typespec generation --- .../models/InternalPersistentAgentsResponseFormat.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/InternalPersistentAgentsResponseFormat.java b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/InternalPersistentAgentsResponseFormat.java index 6bee99a155fb..f2b5fb59408e 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/InternalPersistentAgentsResponseFormat.java +++ b/sdk/ai/azure-ai-agents-persistent/src/main/java/com/azure/ai/agents/persistent/models/InternalPersistentAgentsResponseFormat.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.ai.agents.persistent.models; import com.azure.core.annotation.Fluent; @@ -20,6 +19,7 @@ @Fluent public final class InternalPersistentAgentsResponseFormat implements JsonSerializable { + /* * Must be one of `text` or `json_object`. */ @@ -35,7 +35,7 @@ public InternalPersistentAgentsResponseFormat() { /** * Get the type property: Must be one of `text` or `json_object`. - * + * * @return the type value. */ @Generated @@ -45,7 +45,7 @@ public ResponseFormat getType() { /** * Set the type property: Must be one of `text` or `json_object`. - * + * * @param type the type value to set. * @return the InternalPersistentAgentsResponseFormat object itself. */ @@ -68,7 +68,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of InternalPersistentAgentsResponseFormat from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of InternalPersistentAgentsResponseFormat if the JsonReader was pointing to an instance of * it, or null if it was pointing to JSON null. @@ -82,7 +82,6 @@ public static InternalPersistentAgentsResponseFormat fromJson(JsonReader jsonRea while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("type".equals(fieldName)) { deserializedInternalPersistentAgentsResponseFormat.type = ResponseFormat.fromString(reader.getString()); @@ -90,7 +89,6 @@ public static InternalPersistentAgentsResponseFormat fromJson(JsonReader jsonRea reader.skipChildren(); } } - return deserializedInternalPersistentAgentsResponseFormat; }); } From e96835ab1b443046a7e0415eef1bf373891ae220 Mon Sep 17 00:00:00 2001 From: Jayant Kumar Date: Tue, 13 May 2025 02:13:27 +0530 Subject: [PATCH 6/6] test and codeowners update --- .github/CODEOWNERS | 6 ++++++ .vscode/cspell.json | 3 ++- .../azure/ai/agents/persistent/MessagesAsyncClientTest.java | 1 + .../com/azure/ai/agents/persistent/RunsAsyncClientTest.java | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 94a38f7c6a40..2f2a53ff10d2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -70,9 +70,15 @@ # ServiceLabel: %Advisor # ServiceOwners: @mojayara @Prasanna-Padmanabhan +# PRLabel: %AI +/sdk/ai/ @dargilco @jhakulin + # PRLabel: %AI Model Inference /sdk/ai/azure-ai-inference/ @dargilco @jhakulin @glharper +# PRLabel: %AI Agents +/sdk/ai/azure-ai-agents-persistent/ @dargilco @jhakulin @jayantjha + # ServiceLabel: %AKS # ServiceOwners: @Azure/aks-pm diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 7f164e6e6ad2..35d5bfbef2f7 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -199,7 +199,8 @@ "sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SnowballTokenFilterLanguage.java", "sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/TextTranslationSkillLanguage.java", "sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/TokenFilterName.java", - "sdk/openai/azure-ai-openai-realtime/tsp-location.yaml" + "sdk/openai/azure-ai-openai-realtime/tsp-location.yaml", + ".github/CODEOWNERS" ], "words": [ "adal", diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesAsyncClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesAsyncClientTest.java index c1da16f58a7b..5d50cc6e85fc 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesAsyncClientTest.java +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/MessagesAsyncClientTest.java @@ -101,6 +101,7 @@ public void testCreateMessageWithMetadata(HttpClient httpClient) { .verifyComplete(); } + @Disabled @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") public void testUpdateMessage(HttpClient httpClient) { diff --git a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsAsyncClientTest.java b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsAsyncClientTest.java index e34f214919f0..f108c6dfe411 100644 --- a/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsAsyncClientTest.java +++ b/sdk/ai/azure-ai-agents-persistent/src/test/java/com/azure/ai/agents/persistent/RunsAsyncClientTest.java @@ -70,6 +70,7 @@ private Mono waitForRunCompletionAsync(ThreadRun run) { }); } + @Disabled @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.ai.agents.persistent.TestUtils#getTestParameters") public void testCreateAndRetrieveRun(HttpClient httpClient) {